Click here to Skip to main content
15,896,912 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is how I'm handling the message :

C++
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 :

C++
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
Posted

1 solution

Giggle.

Remove the semicolons from the end of the if statements.

8^P
 
Share this answer
 
Comments
Member 11287295 17-Dec-14 19:59pm    
And that's what programming is about, losing hours (many) of your day to find out a semicolon drove you crazy. Thanks a lot
Jochen Arndt 18-Dec-14 3:22am    
Set the compiler warning level to the maximum.
Your code should then issue the level 3 warning C4390.
nv3 18-Dec-14 4:25am    
Good catch. My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900