Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Change Check Box background color

1,162 views
Skip to first unread message

CK

unread,
Sep 1, 2010, 7:09:08 PM9/1/10
to
Hi,

I try to change the MFC checkbox back ground color (or just
transparent) but it did not show anything but an emptyh gray area. I
did override the OnCtlColor() and on RrawItem() I called the default
but the Check box never show even the callback are called
sueecssfully. As long as I set it as 'BS_OWNERDRAW it never shows the
Check box. Am I missing something?

Thanks in advance.

CK

Message has been deleted

ScottMcP [MVP]

unread,
Sep 1, 2010, 8:14:51 PM9/1/10
to

BS_OWNERDRAW means you are going to paint the control yourself, in
OnDraw. It turns off all of the built in painting. I think you will
have to do that to get nonstandard color.

CK

unread,
Sep 1, 2010, 9:38:32 PM9/1/10
to
Hi,

Thanks for reply. But I did call pDC->SetBkColor() in the CtlColor()
and call the default CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct) in
OnDraw() so it should have the new BK color and draw the check box.
What else do I need to make it work (without draw the spuare and text
myself)?

Thanks again.

ck

Mikel Luri

unread,
Sep 2, 2010, 1:40:11 AM9/2/10
to

Check http://flounder.com/dialog_box_color.htm. It shows how to change
the background of most kinds of controls.

Joseph M. Newcomer

unread,
Sep 4, 2010, 11:27:13 PM9/4/10
to
Did you override OnCtlColor in the subclass of the checkbox? Can you show us the code?
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Joseph M. Newcomer

unread,
Sep 4, 2010, 11:33:10 PM9/4/10
to
SetBkColor has nothing to do with the background color of the control. RTFM. It has to
do with the background color of the text in the control. Create a subclass, override
=WM_CTLCOLOR, return a background brush.
joe

0 new messages