I've wasted most of the weekend on this, so I decided to consult you guys once more..
Here's the problem:
In a window I have a text in a static control. Like this:
HWND hLabel = CreateWindowEx (0, TEXT("STATIC"),
TEXT("some label"), WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, // x,y,w and h are set in WM_SIZE
hwnd, (HMENU)IDLABEL1, ghInst, NULL);
This label has a gray background, no matter what the current background is. So I decided I should perhaps set it to transparent and included this in my windproc:
case WM_CTLCOLORSTATIC:
{
if (LOWORD(wParam) == IDLABEL1)
{
SetBkMode((HDC)wParam,TRANSPARENT);
}
return FALSE;
}
..and the backgound turns white. Nothing works. I tried these:
The result is the same every time: only a white background. Even when I put nothing in the if statement. And without the 'return FALSE' I get a memory error.
I'm probably making a very stupid and obvious mistake here. But what mistake?
-Jay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First of all WM_CTLCOLORSTATIC must ALWAYS return a predefined HBRUSH (as the default background color). A second problem is in (LOWORD(wParam) == IDLABEL1) . This works fine in other messages, but not here since the HDC is in the wParam. To get the ID use: (GetDlgCtrlID((HWND)lParam) == IDLABEL1)
-Jay
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've wasted most of the weekend on this, so I decided to consult you guys once more..
Here's the problem:
In a window I have a text in a static control. Like this:
HWND hLabel = CreateWindowEx (0, TEXT("STATIC"),
TEXT("some label"), WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, // x,y,w and h are set in WM_SIZE
hwnd, (HMENU)IDLABEL1, ghInst, NULL);
This label has a gray background, no matter what the current background is. So I decided I should perhaps set it to transparent and included this in my windproc:
case WM_CTLCOLORSTATIC:
{
if (LOWORD(wParam) == IDLABEL1)
{
SetBkMode((HDC)wParam,TRANSPARENT);
}
return FALSE;
}
..and the backgound turns white. Nothing works. I tried these:
SetTextColor((HDC)wParam,RGB(255,255,0));
SetBkColor((HDC)wParam,RGB(0,0,255));
The result is the same every time: only a white background. Even when I put nothing in the if statement. And without the 'return FALSE' I get a memory error.
I'm probably making a very stupid and obvious mistake here. But what mistake?
-Jay
Hi jay,
First of all WM_CTLCOLORSTATIC must ALWAYS return a predefined HBRUSH (as the default background color). A second problem is in (LOWORD(wParam) == IDLABEL1) . This works fine in other messages, but not here since the HDC is in the wParam. To get the ID use: (GetDlgCtrlID((HWND)lParam) == IDLABEL1)
-Jay
Jay,
Go get some fresh air. You're talking to yourself.
-Jay
Good idea.
-Jay
lol, are you really the same guy, or two with the same name? I vote for mutiple personalities. Call Wayne he has a PhD, maybe he can fix you...
Curtis
I think I am the same guy. I was when I just looked in the mirror.
As for calling Wayne.. I am a PhD as well and therefore beyond salvation.
-Jay
lol
Curtis