WM_CTLCOLORSTATIC for child controls

Feb 11, 2012 at 10:33am
Hello world!
I am trying to change the text and background color of a STATIC control. As long as the controls is created as a child of the main window, the WM_CTLCOLORSTATIC message is sent correctly and the color is changed. If I change its parent (I create it as a child of another static) the WM_CTLCOLORSTATIC no longer receives its ID and the color doesn't change.

I have this
1
2
3
4
5
6
case WM_CTLCOLORSTATIC:
    if((HWND)lParam == my_static_child) {
        SetTextColor((HDC)wParam, RGB(111, 63, 0));
    }
    return (LONG)GetStockObject(WHITE_BRUSH);
break;


It seems like the WM_CTLCOLORSTATIC is sent only for the main window and its first level controls. I should also specify that the parent STATIC control does not contain text, it's just like a panel with a black border. What would you do to make this work? Thanks!
Last edited on Feb 11, 2012 at 10:38am
Feb 11, 2012 at 5:43pm
Only the parent window receives the notification. That is no secret as stated in MSDN. You can always subclass the static control that serves as parent.
Feb 12, 2012 at 12:25am
Yes, it is what I did, subclass the parent control. Thanks!
Topic archived. No new replies allowed.