Thread: Changing static control text color

  1. #1
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318

    Changing static control text color

    I tried to change the static control text color with this code, but this only changes the color of the background:
    Code:
    SetTextColor(hdc,RGB(255,255,255));

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Handle the WM_CTLCOLORSTATIC message, and return a handle to a brush that is the color you want.

  3. #3
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    I tried that too, before SetTextColor:
    Code:
    case WM_CTLCOLORSTATIC:
        return (LRESULT)CreateSolidBrush(RGB(0, 74, 239));
    The static box is colored but the background of the text is still white...

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Well, the problem with text background is solved. I used:
    Code:
    SetBkColor((HDC)lParam,RGB(0, 74, 239));
    in my WM_CTLCOLORSTATIC, but wParam was the real HDC, so it works like this:
    Code:
    SetBkColor((HDC)wParam,RGB(0, 74, 239));
    But actually my first question was, how can I change the color of the TEXT not the background of the text.

  5. #5
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    SetTextColor still didn't work?

  6. #6
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    It works, but it changes the color of the text's background not the color of the text.

  7. #7
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Ok, got that working too...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  2. static text color/background color
    By braindude in forum C++ Programming
    Replies: 1
    Last Post: 07-06-2003, 05:58 AM
  3. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 07:48 PM
  4. changing static text
    By codec in forum Windows Programming
    Replies: 2
    Last Post: 03-23-2002, 09:45 PM
  5. Outputting String arrays in windows
    By Xterria in forum Game Programming
    Replies: 11
    Last Post: 11-13-2001, 07:35 PM