how WM_CTLCOLOREDIT works ?

Started by
4 comments, last by Leaguefun 21 years, 4 months ago
I''m trying to change the color of the edit control with WM_CTLCOLOREDIT message, but I don''t know why its not works. MSDN said that SendMessage(HWND, WM_CTLCOLOREDIT, (WPARAM)hdc, (LPARAM)hwnd), but .......
Advertisement
you respond to it in wndproc of the parent window.

in your wm_ctlcoloredit handler, you can use the HDC that''s in wParam to change background color and font for the edit control that sent you the message.
Do you mean ?

HDC hdc;
SendMessage(HWND, WM_CTLCOLOREDIT, (WPARAM)hdc, (LPARAM)HWND);
SetBkColor(hdc, RGB(0,255,0));

no.

write a handler for wm_ctlcoloredit in your main wndproc.

call setbkcolor there using (HDC) wParam as the device context.
LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
.....
case WM_CTLCOLOREDIT:
SetBkColor((HDC)wParam, RGB(0,255,0));
break;
....
}


Is that right ?
should be. does it work?

This topic is closed to new replies.

Advertisement