Thread: MFC: Change the color of static text with button press?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    OnCtlColor() is called right before a control is to be drawn.
    The returned brush will be used to draw the control's background.
    Use pDC to set the foreground and background text color and background mode.

    1. Store the text color as a member variable and change it on a button press.
    2. Don't return your own brush, return what CDialog::OnCtlColor() returns.

    gg

  2. #2
    Registered User
    Join Date
    Oct 2002
    Posts
    72
    Got it working - thanks!

    The only thing I'll add for anyone else that attempts this, is that you need to do the Invalidate(); UpdateWindow(); after you change the color in the buttonclick() function.

    Last edited by BrianK; 06-16-2004 at 11:13 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. uploading file to http server via multipart form data
    By Dynamo in forum C++ Programming
    Replies: 1
    Last Post: 09-03-2008, 04:36 AM
  2. [GLUT] Pointers to class methods
    By cboard_member in forum C++ Programming
    Replies: 13
    Last Post: 02-16-2006, 04:03 PM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. Accessing a Specific Text Line Inside CEditView :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-14-2002, 08:12 PM
  5. changing static text
    By codec in forum Windows Programming
    Replies: 2
    Last Post: 03-23-2002, 09:45 PM