Jump to content
  • Advertisement
Sign in to follow this  


This topic is 5055 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

There's no WINAPI section, so I thought this the most appropriate forum... I am trying to use the WM_CTLCOLORBTN message to change the colors of things in my buttons. It seems to work on every other type of control in my dialog (list boxes, static text, edit boxes, etc.) and even my dialog itself (with the correct messages WM_CTLCOLORSTATIC etc.) but not for buttons for some reason. Any Ideas? Here's my message handling code:
			HDC e_dc = (HDC)wParam;
			j = (int)GetWindowLong((HWND)lParam,GWL_USERDATA);
				COLORREF col = coms.brushes[coms.sel_brush].color_vals[j];
				COLORREF inv_col = (~col)&0x00FFFFFF;
				HBRUSH br = CreateSolidBrush(col);
				return (BOOL)br;

[/source] Thanks, ~SPH EDIT: My debugger tells me that I do get to the return statement, so it is getting run. And the cast to BOOL works in all other cases, and is suggested in the MSDN documentation.

Share this post

Link to post
Share on other sites
From MSDN (basically it doesn't work for system buttons because they require multiple brushes). That message is kinda misleading, but it should work for
radio buttons and check boxes, which are types of buttons.

By default, the DefWindowProc function selects the default system colors
for the button. Buttons with the BS_PUSHBUTTON, BS_DEFPUSHBUTTON, or
BS_PUSHLIKE styles do not use the returned brush. Buttons with these
styles are always drawn with the default system colors. Drawing push
buttons requires several different brushes-face, highlight and shadow-but
the WM_CTLCOLORBTN message allows only one brush to be returned. To provide
a custom appearance for push buttons, use an owner-drawn button.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!