This is how I'm handling the message :
case WM_CTLCOLORSTATIC:
{
if (GetDlgItem(hwnd, 155) == (HWND)lParam);
{
HDC hDC = (HDC)wParam;
SetTextColor(hDC, RGB(255, 0, 0));
return (LRESULT)GetStockObject(HOLLOW_BRUSH);
}
if (GetDlgItem(hwnd, 151) == (HWND)lParam || GetDlgItem(hwnd, 153) == (HWND)lParam);
{
HDC hDC = (HDC)wParam;
SetTextColor(hDC, RGB(0, 0, 0));
return (LRESULT)GetStockObject(HOLLOW_BRUSH);
}
}
And how static text labels are created :
EncoderLabel = CreateWindowEx(NULL, L"STATIC", L" Encoder ", WS_CHILD | WS_VISIBLE, 27, 50, 57, 16, hwnd,(HMENU)153, GetModuleHandle(NULL), NULL);
ChooseEncoding = CreateWindowEx(NULL, L"STATIC", L"Choose Encoding firstly !", WS_CHILD | WS_VISIBLE, 200 - (165/2), 37, 165, 16, hwnd,(HMENU)155, GetModuleHandle(NULL), NULL);
outputLabel = CreateWindowEx(NULL, L"STATIC", L" output ", WS_CHILD | WS_VISIBLE, 27, 240, 37, 16, hwnd,(HMENU)151, GetModuleHandle(NULL), NULL);
Every control gets printed in red. Doesn't matter which control is being drawn, (HWND)lparam will always match the first if and paint the control in red
Since I got this working on another project, to me it's actually very unusual to face this problem, are common controls possibly the cause of this ? I'm painting them over a TabControl, but they're not Tabcontrol's child. This controls are child of the main frame window