The CreateFont function can be daunting, given the number of arguments, fortunately, most of them accept the default value.
Code:
HFONT CreateFontEasy(HDC hdc, LPCTSTR szFontName, UINT nFontPointSize, BOOL fBold)
{
return CreateFont(-MulDiv(nFontPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 72),
0, 0, 0, fBold ? FW_BOLD : FW_NORMAL,
FALSE, FALSE, FALSE,
DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
szFontName);
}
void SetControlFont(HWND hwnd, int identifier)
{
HDC hdc = GetDC(hwnd);
HFONT hFont = CreateFontEasy(hdc, TEXT("Microsoft Sans Serif"), 10, FALSE);
SendDlgItemMessage(hwnd, identifier, WM_SETFONT, (WPARAM) hFont, MAKELPARAM(TRUE, 0));
ReleaseDC(hwnd, hdc);
}