![]() |
Transparent checkbox? |
Post Reply ![]() |
Author | |
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() 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!
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
in MSDN see WM_CTLCOLOR description/sample.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
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?
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
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)
{
} |
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
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!
|
|
![]() |
|
znakeeye ![]() Senior Member ![]() ![]() Joined: 26 July 2006 Status: Offline Points: 1672 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
|
Oleg ![]() Admin Group ![]() Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
![]() ![]() ![]() ![]() ![]() |
Hi,
Attach modified project and I will point what you do wrong.
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |