Jump to content
  • Advertisement
Sign in to follow this  
phil05

win32: Setting background colors for edit boxes

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

Can you write a code example on how you would set a background color for an edit box? it'd be much appreciated. thanks.

Share this post


Link to post
Share on other sites
Advertisement
Control color handling is WM_CTLCOLOREDIT in Win32, I believe, unless you have it disabled or set to read only in which case it's WM_CTLCOLORSTATIC, or unless it's a rich edit control in which case it's EM_SETBKGNDCOLOR.

If you handle the WM_CTLCOLOREDIT in the parent window like this, the WPARAM is going to be the device context of the control, and you should end up with what you want:

case WM_CTLCOLOREDIT:
hdc = (HDC)wParam;
SetTextColor(hdc, RGB(255,0,0)); /* red */
SetBkColor(hdc, RGB(255,255,0)); /* yellow */
return GetSysColorBrush(COLOR_3DHILIGHT); /* hilight colour */


-fel

Share this post


Link to post
Share on other sites
With an edit control, you can only control the background color and text color with the WM_CTLCOLOREDIT notification. You can't do any other of your own drawing like you can with some controls (e.g. buttons).

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!