I need help changing the font. Any examples, suggestions, and advice would be appreciated.
Here is the code I'm trying to use to change the font.
SelectObject is returning a NULL value, & GetLastError() returns 6 (The handle is Invalid)
Here is the code I'm trying to use to change the font.
- Code:
LOGFONT lFont;
HFONT font;
HFONT prevFont;
HDC hdc;
...
memset(&lFont;, 0, sizeof(LOGFONT)); // fill with 0
lFont.lfHeight = 8; // Request a 8-pixel-height font.
lFont.lfWeight = FW_BOLD;
lstrcpy(lFont.lfFaceName, TEXT("Tahoma"));
font = CreateFontIndirect(&lFont;); // create logical font
hdc = BeginPaint(hWnd, &ps;);
prevFont = (HFONT)SelectObject(hdc, &font;);//**problem**
if (prevFont == NULL)
_ltoa(GetLastError(), buffer, 10); // LastError = 6
....
DrawText(hdc, cstr, cstr.GetLength(), &rt;, DT_LEFT);
EndPaint(hWnd, &ps;);
....
SelectObject is returning a NULL value, & GetLastError() returns 6 (The handle is Invalid)