
How to change the color,size,font of text in a dialog box
Hello,
Basically:
1/ To change the font of a control, create the font using
CreateFontIndirect() and then call SetFont() on the control -- in your
dialog box's OnInitDialog() function.
2/ To change the color of a control, handle the WM_CTLCOLOR message.
You will find additional details in FAQ 4.11 of "The MFC Answer Book": How
do I change the font and color of controls in a dialog box? You can find
screen shots and a sample program at
<http://www.mfcfaq.com/mfc_answer_book/contents_details/faq_details/ch...
aq4-11.htm>.
Check out the book's web site at <http://www.mfcfaq.com>!
Find similar and advanced tips and techniques in "The MFC Answer Book".
Good luck!
- Eugene Kain
Author of "The MFC Answer Book -- Solutions for Effective Visual C++
Applications"
Published 1998 by Addison-Wesley. ISBN 0-201-18537-7
** Browse the book online at <http://www.mfcfaq.com> **
** Buy the book at
<http://www.amazon.com/exec/obidos/ASIN/0201185377/mfcfaqcom> **
Quote:
>>Hi all
>>I am quite surprised that I did not get an answer when I posted this
>>yesterday, I would assume it to be a common and simple thing.
>>I have tried using CreateFont and CreatePointFont but allways just get a
>>bolded version of the font that was there before :(
>>Pleas help me out.
>>--
>>Thanks
>>Erik
>>---
>>Telekinesys
>>http://www.telekinesys.co.za
>>Creators of web based business solutions.
>>Erik de Kok
>>Telephone: +27 (0)11 6548820
>>Direct: +27 (0)11 6548840
>>Cell: +27 (0)82 4956304
>Expect nothing, then you won't be disappointed. Did it ever occur to you
>that no-one saw your post yesterday, or that no-one knew the answer?
>You can only change the font of a dialogue box and all its controls at
>design time. Even then you can't change the colour. To change such details
>of all controls at run time you need to (1) create the desired font STYLE
>(size, typeface, bold / italic / underline) and call SetFont() for EACH
>control, and (2) override OnCtlColor() in the dialogue box's class and call
>SetTextColor() and SetBkColor() and return the desired colour brush for
>background painting for EACH control.
>Does this help?
>_ _
>o o Jason Teagle
> <
>Please ONLY respond via e-mail if you want to catch my attention - I don't
>necessarily look at the newsgroups all the time.