Re: Problem with GetTextMetrics and Unicode
From: John Carson (donaldquixote_at_datafast.net.au)
Date: 01/07/05
- Next message: Gnum: "Re: Can't remap more than one color"
- Previous message: Gnum: "Re: modifying an image in a picturebox and keeping new image after pai"
- In reply to: Mark Hatsell: "Problem with GetTextMetrics and Unicode"
- Next in thread: Mark Hatsell: "Re: Problem with GetTextMetrics and Unicode"
- Reply: Mark Hatsell: "Re: Problem with GetTextMetrics and Unicode"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 7 Jan 2005 11:52:37 +1100
"Mark Hatsell" <mark.hatsell@btinternet.com> wrote in message
news:%23WnkRtD9EHA.3376@TK2MSFTNGP12.phx.gbl
> Hello
>
> I am in the process of converting one of my apps to Unicode and have
> run into a problem with GetTextMetrics. Whenever I call
> GetTextMetrics in my Paint function I get a runtime error when the
> function exits stating that the stack has been corrupted around the
> 'textmetrics' variable. This happens when running the app in the
> Visual Studio debugger. If I run the app outside of the debugger I
> get an 'Unhandled Exception' error and the app closes. The
> GetTextMetrics call returns with a sucessful return value. The
> offending code is very simple:
> TEXTMETRIC textmetrics;
> GetTextMetrics(hdc, &textmetrics);
So if you have a program that does nothing except call these two lines,
e.g., a window procedure of
LRESULT CALLBACK WndProc
(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if(message == WM_PAINT)
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
TEXTMETRIC textmetrics;
GetTextMetrics(hdc, &textmetrics);
EndPaint(hwnd, &ps);
return 0;
}
else
return DefWindowProc (hwnd, message, wParam, lParam) ;
}
then you get corruption? I don't think so. The problem is elsewhere in your
program.
Two possibilities occur to me.
1. The problem is in the use you make of textmetrics.
2. The problem is that some other part of your program is writing where it
shouldn't (e.g., beyond the last element in an array) and the Unicode
version has problems simply because the Unicode version takes up more space
and is therefore more likely to overlap the area where the illegal writing
is taking place.
-- John Carson 1. To reply to email address, remove donald 2. Don't reply to email address (post here instead)
- Next message: Gnum: "Re: Can't remap more than one color"
- Previous message: Gnum: "Re: modifying an image in a picturebox and keeping new image after pai"
- In reply to: Mark Hatsell: "Problem with GetTextMetrics and Unicode"
- Next in thread: Mark Hatsell: "Re: Problem with GetTextMetrics and Unicode"
- Reply: Mark Hatsell: "Re: Problem with GetTextMetrics and Unicode"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|