Using GetTextExtentPoint32 to get char width
Hi,
I'm trying to output a single character, get that character's width, and then increase a variable by that amount. Currently, my code looks like this:
In MainWndProc:
Code:
static char ch[2];
LPSTR ch1;
SIZE sz;
size_t * pcch;
Then, in WM_PAINT:
Code:
TextOut(hdc, PosX, PosY * dwCharY, ch, 1);
ch1 = ch;
StringCchLength(ch1, 11, pcch);
GetTextExtentPoint32(hdc, ch1, *pcch, &sz);
PosX += sz.cx;
Unfortunately when I run the program, it crashes after 1 character is output. Anyone got any ideas as to how I can increase the text's x position without having it crash? I'm pretty new to this stuff.
Thanks.