I have some static text on a window which is black, and I would like to change it at runtime using a Colour Chooser dialog. I have successfully obtained the colour, now I just need to change the text! I have read that the WM_CTLCOLORSTATIC message is the one to handle, although this appears to only be for when the control is initially drawn to the screen. Could WM_PAINT be used?
The code for setting the colour I have so far is (in WM_CTLCOLORSTATIC case):
if ((HWND)lParam == GetDlgItem(hWnd, uLabelId)
{
SetBkMode((HDC)wParam, TRANSPARENT);
SetTextColor((HDC)wParam, crLabelTextColour);
return (BOOL)CreateSolidBrush(GetSysColor(COLOR_MENU));
}
I may have got entirely the wrong end of the stick approaching this issue, so any assistance would be greatly appreciated!
You’re on the right track with
WM_CTLCOLORSTATIC. If you want to change the color, then invalidate the control (probably by usingRedrawWindow). That will cause it to be repainted. When it’s repainted, yourWM_CTLCOLORSTATIChandler will be invoked again.