I need to subclass a checkbox, and that is of CButton class. I tried that, and overwrite OnPaint(), however the check box disappears, I guess that is because I would need to paint the checkbox as well, well, that is beyond my knowledge, so I tried to overwrite OnCtlColor, however that doesn't get called.
One post said that I would need to set the ownerdraw flag, I tried that it doesn't work with the following:
I didn't know you could change the color of the text of a CButton
without making it owner drawn.
Can you? If you can then just do that.
If you do go the owner drawn route, then don't do what I did
It seems that BS_AUTOCHECKBOX and BS_OWNERDRAW
do not go together well, but I did not try creating the button
outside of the resource editor
The easiest way to do owner drawn is to create a regular owner
drawn button and use DrawFrameControl() control draw the
check and box. Or you can draw the box and check yourself.
With this method you have to keep track of the state of the check yourself.
Let me know if you need it and I will give you the code
Last edited by souldog; March 9th, 2004 at 04:11 PM.
Wakeup in the morning and kick the day in the teeth!! Or something like that.
"i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."
Make a CFont data member in your dialog.
In OnInitDialog(), create the font you like (look up CreateFont(...)), and set it to be used for your checkbox (using SetFont(...)).
Create OnCtlColor() handler and check if the window pointer passed in is your CheckBox, then set the text color to whatever using pDC->SetTextColor(...);
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
BS_AUTOCHECKBOX and BS_OWNERDRAW can not work together
if you change the buttong to BS_OWNERDRAW style, it is not CheckBox any more. after you have changed the style to BS_OWNERDRAW , the function SetCheck(), GetCheck() will not work.