Click here to Skip to main content
13,458,430 members
Rate this:
Please Sign up or sign in to vote.
See more:
	CFont * pCurFont=GetFont();//Dialog's Font
	if(!pCurFont) return;
	CFont font;

I have a Button in Dialog,When I first Setfont() for it with bBold==True.The Font of the Button 's font is Bold,But when I want to recover it with bBold==false later.
It doesn't work!
Any help?
Posted 3-Jul-12 23:27pm
Updated 3-Jul-12 23:29pm
Soheera 4-Jul-12 6:40am
bBold == True OR bBold = True?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I belive the problem is that you are giving your button a font that is "stored" in a local variable.
CFont font;
-when font goes out of scope, its destructor deletes the font resource. When the button gets redrawn, it will revert to using the system font, which kinda looks bold. So you will see the button's text becoming bold and will think you did ok. Then when you try to set it back to non-bold, you probably do the very same thing, create a local non-bold font object and specify it for your button, but again, when this goes out of scope, it gets destroyed and the button will again use the system font, so you will see that it didn't become "not bold".
Try rewriting your code so the CFont object you want to use with your button remains existent during the lifetime of your button.

Does this help?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180323.1 | Last Updated 4 Jul 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100