Click here to Skip to main content
11,584,556 members (64,957 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VC6 VC7 VC7.1 VS.NET2003 VS2005 , +
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 22-Aug-12 19:50pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Take a look at the article Using colors in CEdit and CStatic[^], it would seem to be what you need.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You could do something like this to set the fonts:

    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...
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 430
1 Sergey Alexandrovich Kryukov 367
2 Dave Kreskowiak 260
3 Richard Deeming 220
4 virusstorm 194
0 OriginalGriff 1,703
1 Sergey Alexandrovich Kryukov 1,267
2 Abhinav S 711
3 Dave Kreskowiak 687
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web03 | 2.8.150707.1 | Last Updated 23 Aug 2012
Copyright © CodeProject, 1999-2015
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