Click to See Complete Forum and Search --> : GetTextMetrics fails.
Quintesence
June 13th, 2003, 11:29 AM
I'm attempting to retrieve text metric information outside of a WM_PAINT message. When I do this the GetTextMetrics function fails and GetLastError returns the error code 2. I need to retrieve the text metrics information outside of the paint event.
Doctor Luz
June 13th, 2003, 12:23 PM
HAve you checked if your HDC is valid?
Quintesence
June 13th, 2003, 12:31 PM
If you mean does the GetDC function fail then no it returns a handle.
Doctor Luz
June 13th, 2003, 12:41 PM
The Error lookup utility says that error number 2 is "System can't find the specified file".
What file finds GetTextMetrics? the font file? Maybe the font is the problem.
Quintesence
June 13th, 2003, 01:09 PM
Ah I found it. You mentioning something being wrong with the font made me double check the method I used to create the font. I had forgotten to zero the LOGFONT structure before I called CreateFontIndirect so it was passing a lot of garbage to the function. Annoyingly, it never failed with the bogus data it received. Thanks for the help it's greatly appreciated.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.