Jump to content
  • Advertisement
Sign in to follow this  
Gink

Setting Button Color / Text WinApi WM_CTLCOLORBTN

This topic is 4865 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!