troubleshooting Question

Change color of edit box with dynamic color

Avatar of jstephe1
jstephe1 asked on
System Programming
4 Comments1 Solution701 ViewsLast Modified:
I'm writing an application in Visual C++ 6.0 on Windows2000.  I currently have a pushbutton that will invoke the CColorDialog interface.  When the user selects a color, I get the color from the CColorDialog and I want to change the color of an edit in the dialog to that new color.

I know how to change the color of edit boxes in general.  My question is, how do you do it with a dynamic RGB value?

In general you create the brush with CreateSolidBrush() somewhere (probably constructor), then in the OnCtlColor function you do something to the effect:

if ( nCtlColor == CTLCOLOR_STATIC )
   int nID = pWnd->GetDlgCtrlID();

   if ( nID == IDC_TEST_EDIT )
     pDC->SetBkColor( RGB(255,0,0) );
     return m_hRedBrush;

you need to return a brush somehow....but it's always changing.....any help would be appreciated.


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros