In my button like control that im making, during the wm_paint message, i send WM_CTLCOLORBTN to the owner before i draw the text and it automaticly sets the text foreground and background colors. But how do use the HBRUSH it returns to color the rest of the button? Do i use SelectObject on it for when i use DrawText? Or do i have to draw a rect with the color?
Posted on 2002-07-06 22:02:22 by ChimpFace9000
I think you will receive the HBRUSH as the returned value of SendMessage:

LRESULT SendMessage(
HWND hWnd, // handle to destination window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter


Return Values
The return value specifies the result of the message processing; it depends on the message sent.
Posted on 2002-07-07 03:07:02 by LuHa
I know. Thats not what i asked about.
Posted on 2002-07-07 13:31:24 by ChimpFace9000
The brush returned from WM_CTLCOLORxxx should be used as the background brush for your window. You'll probably want to call FillRect to fill the background.
Posted on 2002-07-07 19:48:02 by chorus
Is it better to use FillRect or Rectangle?
Posted on 2002-07-07 21:32:38 by ChimpFace9000
Personally, I'd use FillRect. Two reasons:

1) You don't have to worry about calling SelectObject/ DeleteObject and tracking the old brush
2) The parameters are nice and easy to get

Performance wise, I've never noticed a difference. One thing to note however, is that Rectangle draws a border too. If you need a border, then you may as well use Rectangle. If you don', however, just use FillRect

Posted on 2002-07-07 21:42:48 by chorus