Your function shouldn't work! You forgot to select it into the HDC.
That is imperative. Also you should know that when you DO select it with SelectObject(), that function will return a handle to the previous font, should you wish to restore it later.
ie:
Code:
HFONT font = CreateFont( 25, 15, 0, 0, FW_EXTRABOLD, 0, 0, 0, ANSI_CHARSET, 10, PROOF_QUALITY, VARIABLE_PITCH, FF_ROMAN, "courier");
HFONT previous = (HFONT)SelectObject(hdc, font);
Try this:
Code:
HFONT SetWFont( HWND handle, UINT winIdent, UINT fontSize, LPSTR fontFamily )
{
HFONT hFont;
HDC hdc;
long lfHeight;
hdc = GetDC(handle);
lfHeight = -MulDiv(fontSize, GetDeviceCaps(hdc, LOGPIXELSY), 72);
hFont = CreateFont(lfHeight, 20, 0, 0, 0, 0, 0, 0, ANSI_CHARSET,10, PROOF_QUALITY, VARIABLE_PITCH, FF_ROMAN, fontFamily);
SelectObject(hdc, hFont);
ReleaseDC(handle, hdc);
return hFont;
}