Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In order to obtain font dialog below code
CFontDialog dlg;
if(dlg.DoModal()==IDOK)
{
//GetCurrentFont() for font
//Getcolor() gets color choosed by user
//SetFont() can be used to setting the font
}

so here my question is which function can be used to set the color to the text which is opted by the user.
Posted

Take a look at the article Using colors in CEdit and CStatic[^], it would seem to be what you need.
 
Share this answer
 
You could do something like this to set the fonts:

C++
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 16;
_tcsncpy_s(lf.lfFaceName, LF_FACESIZE, _T("Arial"), 7);
HFONT hFont = ::CreateFontIndirect(&lf);
CFont* pfont = CFont::FromHandle(hFont);
m_wndEditBox.SetFont(pFont);


You can also override the OnCtlColor function...
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900