Thank you kuphryn for your suggestion, but it is not working for me. I did try with the code you gave, but even then, the font is not changing.
Any idea why this?
CFont Font;
Font.CreatePointFont(120, _T("Courier")); // creates a 12-point-Courier-font
m_Button.SetFont(&Font); // with a member variable associated
GetDlgItem(IDC_BUTTON)->SetFont(&Font); // without a member variable associated
The 'CFont' variable needs to be a member variable of the dialog containing the button...
Andreas,
your solution is not working for windows XP when the manifest file is compiled with the application for styles.
I cannot get the XP style button to change font,
please help!
sure, here is my code...
it does not work in onInitDlg....
and it does not work in any other functions called at any time.....
this code will set the font fine when the Manifest file is not included at compile time. But this is not acceptable because I want to support XP syles,
thanks in advance for any replies you have...
Code:
//create the button font
//CFont bFont; //this is a member variable in the header class
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));// zero out structure
strcpy(lf.lfFaceName, "Verdana");
lf.lfHeight = 30;
lf.lfWeight = FW_BOLD; // nWeight
bFont.CreateFontIndirect(&lf);
//bFont.CreatePointFont(140,"Verdana"); //this also does not work
GetDlgItem(IDC_BUTTON1)->SetFont(&bFont);
//end button font
I copy and pasted that code directly out of my program,
I think Visual Studio 2003 sucks! could that be the problem?
I know everytime I use a Time Control in a program, when I close the compiler, and reopen it, suddenly the stupied compiler has converted my time control into a date control, Microsoft sucks.
What compiler are you using, which Visual Studio version?
Please let me know, thanks!
This is a problem, my code works perfect for every control Except a CButton! I have VS 2002 and VS2003, both compilers will not set the font for a CButton, no matter what I do,
Anyone have any ideas?
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.