Print Page | Close Window

Transparent checkbox?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=6731
Printed Date: 19 August 2025 at 7:17pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Transparent checkbox?
Posted By: znakeeye
Subject: Transparent checkbox?
Date Posted: 26 March 2007 at 9:12am
I have a CWnd-derived window with a black background. Inside this window, I have a checkbox (CButton) with the WS_EX_TRANSPARENT style set. Of course, the rectangle of this checkbox is excluded in CMyWindow::OnPaint, using ExcludeClipRect.
 
Why does my checkbox look like this? How do I make it transparent?
 
 
Thanks!



Replies:
Posted By: Oleg
Date Posted: 26 March 2007 at 10:36am
Hi,
 
in MSDN see WM_CTLCOLOR description/sample.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: znakeeye
Date Posted: 26 March 2007 at 12:04pm

Hi,

The problem is that WM_CTLCOLOR is not received. I've tried to capture WM_CTLCOLORBTN too, with no success.

Here is my code:
 
In the message map of my CWnd-derived class: ON_WM_CTLCOLOR()
 
CMyDerivedWnd::Create(...):
m_button.CreateEx(WS_EX_TRANSPARENT, _T("BUTTON"), _T("&Transparency?"), WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | BS_CHECKBOX, rcButton, this, IDC_MYBUTTON);
 
HBRUSH CMyDerivedWnd::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    // Never called... could this be due to the BS_CHECKBOX style?
    return CWnd::OnCtlColor(pDC, pWnd, nCtlColor);
}
 
Any ideas? What am I missing here?


Posted By: Oleg
Date Posted: 27 March 2007 at 1:14am
Hi,
 
WM_CTLCOLOR is sent to parent of button. In button you can catch reflected message:
 
ON_WM_CTLCOLOR_REFLECT()
HBRUSH CMyDerivedWnd::CtlColor(CDC* pDC, UINT nCtlColor)
{
pDC->SetTextColor( m_clrText );    // text
pDC->SetBkColor( m_clrBkgnd );    // text bkgnd
return m_brBkgnd;                // ctl bkgnd

}


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: znakeeye
Date Posted: 27 March 2007 at 9:22am
I've done some testing, and it seems that WM_CTLCOLOR is only sent to the parent window if it has been created from a dialog resource. My CWnd-derived class does not receive this message. Do you know the cause of this?
 
Anyway, I will try your solution, though I did not want to create another button class .
 
Thanks for your advice!


Posted By: znakeeye
Date Posted: 29 March 2007 at 3:24am
It's not working :(. Even if I subclass CButton and override WM_CTLCOLOR, as you described, I do not get this message. Neither is it handled in CMyWindow::PreTranslateMessage.
 
WM_CTLCOLOR is not sent to the parent window. What can be the reason for this? This is what I know:
1) My parent window is a modeless dialog (most of the code was taken from CColorSelectorCtrl).
2) My check box is created dynamically in CMyWindow::Create(...).
 
To reproduce this, all you need to do is adding a check box in the color picker control and then try making it transparent.
 
Any ideas? Thanks.


Posted By: Oleg
Date Posted: 29 March 2007 at 4:05am
Hi,
 
Attach modified project and I will point what you do wrong.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net