Setting Button Color / Text WinApi WM_CTLCOLORBTN

Started by
2 comments, last by Verg 18 years, 8 months ago
How would I use WM_CTLCOLORBTN to set the background of a button? I tried using SetBkColor((HDC)wParam,RGB(#,#,#)) in this message but it has no effect. What else do I need to do?
Advertisement
Well, for starters, did you create the button as an owner-drawn button. Processing the WM_CTLCOLORBTN doesn't work if not.

If you haven't done so you might want to read this.
<span class="smallfont">That is not dead which can eternal lieAnd with strange aeons even death may die.   -- "The Nameless City" - H. P. Lovecraft</span>
yeah I used BS_OWNERDRAW. Petzolds book says you can do it from WM_COLORBTN but then there is no example of how to do it, although he says you have to use SetBkColor. Ive figured out how to do it with WM_DRAWITEM messages, but not with WM_CTLCOLORBTN.

edit: Ill just use WM_DRAWITEM
When you process WM_CTLCOLORBTN, (in your WndProc, likely) you have to return a handle to a brush (HBRUSH)... the brush you want to paint the button's background with.
my_life:          nop          jmp my_life
[ Keep track of your TDD cycle using "The Death Star" ] [ Verge Video Editor Support Forums ] [ Principles of Verg-o-nomics ] [ "t00t-orials" ]

This topic is closed to new replies.

Advertisement