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?
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.
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.
I know. Thats not what i asked about.
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.
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.
Is it better to use FillRect or Rectangle?
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
--Chorus
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
--Chorus