Click here to Skip to main content
15,881,089 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello together,

I'd like to change the color of either the checkmark of a checkbox or the background color of the box itself. So, I don't want to change the color of the control's background (I found several articles on that using OnEraseBkgnd and OnCtlColor), I'd rather like to change the white color around the checkmark. Is there a way how I can do that without having to draw the complete control on my own?

Kind regards
Marcus
Posted
Comments
Shahriar Iqbal Chowdhury/Galib 5-Jan-11 15:03pm    
you can use the image trick. You will need 2 images of same size one is checked image, other is unchecked image feel free to put color on images.put a unchecked image and on click event replace the unchecked image with the checked one.For reference checkout ExtJs checkbox

1 solution

Drawing it yourself can be done easily using bitmap resources - one bitmap for each state.

Regards
Espen Harlinn
 
Share this answer
 
Comments
Manfred Rudolf Bihy 5-Jan-11 15:21pm    
Sounds sensible! 5+
Can this be done with the standard CheckBox control or does he need to roll his own?
Espen Harlinn 5-Jan-11 15:32pm    
This can be done with standard checkbox - BS_CHECKBOX | BS_OWNERDRAW and WM_DRAWITEM
or by subclassing. Personally I prefer subclassing ...
Manfred Rudolf Bihy 5-Jan-11 15:43pm    
Good one! () Oops I ran out of fives :)
khb 6-Jan-11 4:46am    
Thank you! So it looks like I have to do some drawing ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900