I have a GUI written in MFC for a Windows CE device. However I need to resize some of the buttons and their corresponding text. I can't figure out how to change font size. The following code fragments did not help:
Trial 1:
*CFont fnt2;
fnt2.CreateFont(10, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH, L"MS Shell Dlg");
m_btnForceAnalog.SetFont(&fnt2);
fnt2.Detach();
Trial 2:
LOGFONT lf;
memset(&lf,0,sizeof(LOGFONT));
lf.lfHeight = 5; // Request a 100-pixel-height font
// DP and LP are always the same on CE - The conversion below is used by CFont::CreateFontIndirect
HDC hDC=::GetDC(NULL);
lf.lfHeight = ::GetDeviceCaps(hDC,LOGPIXELSY) * lf.lfHeight;
::ReleaseDC(NULL,hDC);
//ReleaseDC(/*NULL,*/hDC);
lf.lfHeight /= 720; // 72 points/inch, 10 decipoints/point
if(lf.lfHeight > 0)
lf.lfHeight *= -1;
OutputDebugString(L"\nAbout to call the setfont\n");
lstrcpy(lf.lfFaceName, _T("Arial"));
HFONT font =::CreateFontIndirectW(&lf);
CWnd* myButton = GetDlgItem(IDC_FORCE_ANALOG_BTN); //The Button with regular font
myButton->SendMessageW(WM_SETFONT, (WPARAM)font, TRUE);