Hi Everyone,
I'm simply trying to change the size of the text within a Windows Mobile 5.0 MFC device button. In Windows CE, buttons usually have a standard font and text size. I am not able to change the text size of the button or it's font.
The following is a quick snippet of what I'm shooting for:
// Create fonts
CFont theFont;
LOGFONT lf;
memset(&lf,0,sizeof(LOGFONT));
lf.lfHeight = 20; // Request a 100-pixel-height font
lstrcpy(lf.lfFaceName, _T("Arial"));
theFont.CreatePointFontIndirect(&lf);
CWnd* myButton = GetDlgItem(IDC_BUTTON); //The Button with regular font
myButton->SetFont(theFont, TRUE); //Change the button font & text size
Any ideas The font and text size just doesn't change.
Thanks!

Change Button Text Size & Font
Serge Luca
Hi,
I suggest to call the WM_SETREDRAW message after setting the font. Usage of WM_SETREDRAW is given below
SendMessage(pHwnd,WM_SETREDRAW,(WPARAM)TRUE,NULL);
You can also use the SetRedraw() function to redraw the font.
coldnebraskablue
Hi,
I shall try to look into the matter soon.
Thanks
CharlieDigital
Yes, this did solve the problem. However, I still wonder why it didn't work with the original code that I posted above It would be cleaner to do it the other way.
Thanks! :)
echobaseuk
Hi,
Looks strange. I shall look into the matter in the meanwhile try using the font APIs directly.
memset(&lf,0,sizeof(LOGFONT));
lf.lfHeight = 20; // 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);
lf.lfHeight /= 720; // 72 points/inch, 10 decipoints/pointif(lf.lfHeight > 0)
lf.lfHeight *= -1;
lstrcpy(lf.lfFaceName, _T("Arial"));
HFONT font =::CreateFontIndirectW(&lf);
CWnd* myButton = GetDlgItem(IDC_BUTTON); //The Button with regular font
myButton->SendMessageW(WM_SETFONT, (WPARAM)font, TRUE);
Should work. I shall investigate into the matter further.
Hope this helps.
Thanks
Vince Stone
I am developing a dialog based application on Windows CE 5.0 using eMbedded Visual C++ 4.0. I tried the code in your post and I was not able to change the fonts. I guess even though I had selected a bonch of fonts from catalog items and put the font files under windows folder, I didn't install the fonts properly. Could anyone outline the steps to install additional fonts to windows CE Or is there anything else I am missing
Thanks.