How can I customize the color of a control, like buttons and and text edit boxes; without using any classes or mfc, just plain api?
Thank you.
How can I customize the color of a control, like buttons and and text edit boxes; without using any classes or mfc, just plain api?
Thank you.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
This comes up a lot so a board search will give you lots of information.
Generally you handle WM_CTLCOLOR* messages which are sent to the control parent and return an HBRUSH that's used to paint the control background. This works for most controls, buttons being the notable exception. Some control message are:
WM_CTLCOLORSTATIC
WM_CTLCOLREDIT
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
If I understand it right, with WM_CTLCOLOR I know when the control is going to be drawn, but how do I change it's colors?
Also why the button is an exception?
thanks
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
>>how do I change its colors<<
For example:
>>Also why the button is an exception?<<From msdn for WM_CTLCOLOREDIT:
If an application processes this message, it must return the handle of a brush. The system uses the brush to paint the background of the edit control.
board search
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
just a small problem with that... windows repaints over it, so the only thing in the edit box control that changes are the edges... so it's still white(default color)
Last edited by Devil Panther; 02-25-2004 at 02:45 PM.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
The WPARAM of the WM_CTLCOLOR* messages is the control HDC which you can use to, for example, SetBkMode or SetBkColor. You can also SetTextColor with that device context, too.
It may be that text you are adding to the control is being drawn with a default background colour. Use SetBkMode or SetTextColor to modify this if you need to, eg:Code:SetBkMode((HDC)wParam,TRANSPARENT);
Last edited by Ken Fitlike; 02-25-2004 at 04:18 PM.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
i see... thanks alot.
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.
Only one last problem with the edit boxes, if the control is empty and I focus on it, it returns to the default color, and then when I type something it changes to the chosen color. why? how do I fix it?
"I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe
http://www.Bloodware.net - Developing free software for the community.