Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Transparent checkbox?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Transparent checkbox?

 Post Reply Post Reply
Author
Message
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Topic: Transparent checkbox?
    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!
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 26 March 2007 at 10:36am
Hi,
 
in MSDN see WM_CTLCOLOR description/sample.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.145 seconds.