I have created a edit control with ES_PASSWORD . I want to change the color of my static box to grey.
case WM_CTLCOLOREDIT:
{
HDC hdc = (HDC) wParam ;
开发者_开发知识库 SetBkMode( hdc, RGB(65, 65, 65));
return (LRESULT)GetStockObject(NULL_BRUSH);
}
But still by edit control is white color :(
Please help me. If there are more then one edit control , is there to h
Your message handler should look like this:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CTLCOLOREDIT:
{
HBRUSH hBrush = CreateSolidBrush(RGB(255,0,0));
::SelectObject((HDC)wParam, (HGDIOBJ)hBrush);
break;
}
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Make sure you don't cal DefWindowProc, that will defeat the override.
精彩评论