Hi, I'm having confusion with the effect of the return value of WM_CTLCOLORSTATIC with read only edit controls.
In my main WndProc's WM_CREATE's handler includes:
Code:
hwndInfoEdit = CreateWindowEx(NULL, TEXT("edit"), NULL, WS_CHILD | WS_VISIBLE |
ES_MULTILINE | ES_AUTOVSCROLL |
ES_READONLY, 25, 25, 25, 25, hWnd, NULL,
((LPCREATESTRUCT)lParam) -> hInstance, NULL);
Which should create a read only edit control.
I also handled WM_CTLCOLORSTATIC in the same WndProc:
Code:
case WM_CTLCOLORSTATIC:
{
HDC hdcStatic = (HDC)wParam;
HWND hwndStatic = (HWND)lParam;
if(hwndStatic == hwndInfoEdit)
{
MessageBeep(0);
return (LRESULT)GetStockObject(BLACK_BRUSH);
}
}
The MessageBeep did play a beep, so I'm sure the return line after that did run.
But for some reason, the edit control's background color is white. I returned a handle to a black brush, so why did it turn out white? I replaced BLACK_BRUSH with GRAY_BRUSH and a few other values, but it still makes the background color white.
I tried including a SetBkColor(hdcStatic, RGB(0,0,0)); before the return and that made the background black, but I'm trying to understand why I can't use the return to get a black background.
Please reply, any help is greatly appreciated.