-
problems with CTLCOLOR's
i have WM_CTLCOLORLISTBOX and WM_CTLCOLOREDIT
Code:
HBRUSH lbColor = CreateSolidBrush(RGB(0,0,0));
HBRUSH editColor = CreateSolidBrush(RGB(0,0,0));
Code:
case WM_CTLCOLORLISTBOX:
SetBkColor((HDC)wParam, RGB(0,0,0));
SetTextColor((HDC)wParam, RGB(255,255,255));
return ((LRESULT)lbColor);
case WM_CTLCOLOREDIT:
SetBkColor((HDC)wParam, RGB(0,0,0));
SetTextColor((HDC)wParam , RGB(255,255,255));
return ((LRESULT)editColor);
the problem is when i resize the window, after doing this a few times it paints the controls back to there standard color(white back black font)
does any one know a solution to this, thanks
-
Very possibly with the way you're creating those brush handles but without more information it's hard to say - where in your program are they declared and what scope do they have, for example.
Still, if all you want is a black background then just use the stock black brush, ie.
Code:
case WM_CTLCOLORLISTBOX:
SetBkColor((HDC)wParam, RGB(0,0,0));
SetTextColor((HDC)wParam, RGB(255,255,255));
return ((LRESULT)GetStockObject(BLACK_BRUSH));
case WM_CTLCOLOREDIT:
SetBkColor((HDC)wParam, RGB(0,0,0));
SetTextColor((HDC)wParam , RGB(255,255,255));
return ((LRESULT)GetStockObject(BLACK_BRUSH));
At least this will give you a result and you won't have to worry about gdi resource leaks. See GetStockObject for more details.