Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Color change in MFC Textbox Control

510 views
Skip to first unread message

marathoner

unread,
Apr 16, 2008, 3:12:12 PM4/16/08
to
How do I control/change the color of the text in an CEdit textbox control?

Marathoner


WJ

unread,
Apr 16, 2008, 3:37:01 PM4/16/08
to
try using CRichEditCtrl
example ----
CHARFORMAT hdgFormat2;
m_ctrOnBottomStatus.GetDefaultCharFormat( hdgFormat2 );
hdgFormat2.dwMask = CFM_BOLD | CFM_SIZE | CFM_COLOR;
hdgFormat2.dwEffects = 0;
hdgFormat2.yHeight = 165;
if(bBlue)
hdgFormat2.crTextColor = RGB( 10, 10, 255 ); //blue
else
hdgFormat2.crTextColor = RGB( 255, 10, 10 ); //red

// strcpy( hdgFormat2.szFaceName , "Bookman Old Style" );
hdgFormat2.cbSize = sizeof( hdgFormat2 );

//On Bottom Status
refEdit.SetDefaultCharFormat( hdgFormat2);
refEdit.SetBackgroundColor( false, GetSysColor( COLOR_3DFACE));

Doug Harrison [MVP]

unread,
Apr 16, 2008, 3:41:37 PM4/16/08
to
On Wed, 16 Apr 2008 15:12:12 -0400, "marathoner" <rajk...@msn.com.invalid>
wrote:

>How do I control/change the color of the text in an CEdit textbox control?

This article should help you:

Using colors in CEdit and CStatic
http://www.codeproject.com/KB/static/coloredit_colorstatic.aspx

--
Doug Harrison
Visual C++ MVP

marathoner

unread,
Apr 17, 2008, 12:23:57 PM4/17/08
to
This seems to work for setting the background color, but the text color
doesn't change.

"WJ" <W...@discussions.microsoft.com> wrote in message
news:77C3F42C-1331-47DB...@microsoft.com...

marathoner

unread,
Apr 17, 2008, 2:25:09 PM4/17/08
to
Never mind. I forgot to set dwEffects to 0.

Marathoner
"marathoner" <rajk...@msn.com.invalid> wrote in message
news:u5%23MrdKo...@TK2MSFTNGP05.phx.gbl...

AliR (VC++ MVP)

unread,
Apr 17, 2008, 5:11:36 PM4/17/08
to
You can also change the color of the edit by catching the WM_CTLCOLOR for
the edit control and set the color on the DC that is passed in.

AliR.


"marathoner" <rajk...@msn.com.invalid> wrote in message

news:OtuaDX$nIHA...@TK2MSFTNGP04.phx.gbl...

0 new messages