From: Yawar on
Hi Dana, I came across the exact same problem with unicode vs. ansi version incompatibility between transparency in check box buttons. I am using Visual Studio 2008 and I don't know how to generate a manifest file of my own, if I were to, how would I tackle the side by side assemblies, dev studio generates one for me after looking for DLLs at the right places and putting their versions in the manifest correctly.

Please do let me know
Yawar



Dn wrote:

David...thanks to your reply that really got to the point.
20-Feb-08

David...

thanks to your reply that really got to the point. I just resolved my
problem :)
my project was manifested and utilized version 6 common control when i
called InitCommonControls().
what i do then is using my own manifest file (instead of let the project
generate one for me) for creating and embedding the final manifest.

Thanks
Dana

"D(a)na" wrote:

Previous Posts In This Thread:

On Tuesday, February 12, 2008 5:39 AM
Dn wrote:

transparent CheckBox/radioBox
hello All..

there is something weird in my project when dealing with transparent
checkbox or radio box.. I wanna have a transparent-background CheckBox and
RadioBox
I ve tried using owner draw and implement WM_CTLCLR. The checkbox/radiobox
background will turn to black if i set my project Unicode-support. But,
everything work well if i work in a non-unicode project. Since i need to
support
Unicode, its so troublesome.
I dont get what's happening, so need your expertist ..FYI, Im using visual
studio 2005

thanks in advance

On Tuesday, February 12, 2008 10:37 AM
David Ching wrote:

Re: transparent CheckBox/radioBox
"D(a)na" <Dna(a)discussions.microsoft.com> wrote in message
news:BBF5389F-C6CD-4152-8AA0-477EE265ADE1(a)microsoft.com...

I have UNICODE project with transparent checkboxes and radio buttons. But
only the text to the right of these controls are transparent. The actual
checkbox/radio button can't be transparent (or at least I haven't found a
way). In fact, I have code that has:

HBRUSH CBaseWnd::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CWnd::OnCtlColor(pDC, pWnd, nCtlColor);

DWORD dwStyle = pWnd->GetStyle();
if ( dwStyle &
(BS_AUTORADIOBUTTON | BS_RADIOBUTTON | BS_AUTOCHECKBOX |
BS_CHECKBOX) )
{
// Radio buttons and checkboxes have ugly gray backgrounds that
// stick out when placed over a white background; paint the
background
// in white for a better blend
hbr = (HBRUSH) GetStockObject (WHITE_BRUSH);
}

return hbr;
}


So I explicitly set the color of the checkbox/radio button here.

-- David

On Tuesday, February 12, 2008 11:12 AM
AliR \(VC++ MVP\) wrote:

This is the way I implemented a transparent checkbox/radiobuttonAs with
This is the way I implemented a transparent checkbox/radiobutton
As with David's, mine only has the text part transparent. If you want the
actual box transparent, you will have to create your own control from
scratch.

// CTransparentCheckBox

class CTransparentCheckBox : public CButton
{
DECLARE_DYNAMIC(CTransparentCheckBox)

public:
CTransparentCheckBox();
virtual ~CTransparentCheckBox();

protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg HBRUSH CtlColor(CDC* /*pDC*/, UINT /*nCtlColor*/);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
};


//////////////////////////////////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNAMIC(CTransparentCheckBox, CButton)
CTransparentCheckBox::CTransparentCheckBox()
{
}

CTransparentCheckBox::~CTransparentCheckBox()
{
}


BEGIN_MESSAGE_MAP(CTransparentCheckBox, CButton)
ON_WM_CTLCOLOR_REFLECT()
ON_WM_ERASEBKGND()
END_MESSAGE_MAP()



// CTransparentCheckBox message handlers


HBRUSH CTransparentCheckBox::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
{
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(HOLLOW_BRUSH);
}

BOOL CTransparentCheckBox::OnEraseBkgnd(CDC* pDC)
{
return TRUE;
}


AliR.



"D(a)na" <Dna(a)discussions.microsoft.com> wrote in message
news:BBF5389F-C6CD-4152-8AA0-477EE265ADE1(a)microsoft.com...

On Tuesday, February 12, 2008 8:19 PM
Dn wrote:

thanks for the reply , AliR& David..i implemented exactly the same way..
thanks for the reply , AliR& David..

i implemented exactly the same way.. but as you said, cannot make the
checkbox/radiobox background transparent. what I'm courious at is that it
work well in non-Unicode program.
1. Supposing that Unicode use different library from a non-unicode one, does
it mean that it has different implementation for this case? whats happening
here?
2. for making it from the scratch, coudl you kinly advise some clue?

here was my implementation for the CButton implemented class. i have made
sure that the message was properly captured.

//----------------------------------------------------------------------
class radiobutton : public CButton
{
DECLARE_DYNAMIC(radiobutton)
public:
radiobutton();
virtual ~radiobutton();

protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
public:
afx_msg HBRUSH CtlColor(CDC* pDC, UINT/* nCtlColor*/);
};

//------------------------------------------
IMPLEMENT_DYNAMIC(radiobutton, CButton)
radiobutton::radiobutton()
{
}
radiobutton::~radiobutton()
{
}

BEGIN_MESSAGE_MAP(radiobutton, CButton)
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR_REFLECT()
END_MESSAGE_MAP()

// radiobutton message handlers
BOOL radiobutton::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
}

HBRUSH radiobutton::CtlColor(CDC* pDC, UINT /*nCtlColor*/)
{
// TODO: Change any attributes of the DC here
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH)GetStockObject(HOLLOW_BRUSH);
}
//----------------------------------


thanks..
D(a)na



"AliR (VC++ MVP)" wrote:

On Tuesday, February 12, 2008 9:39 PM
David Ching wrote:

Re: transparent CheckBox/radioBox
"D(a)na" <Dna(a)discussions.microsoft.com> wrote in message
news:A44B7414-3DB3-4B25-9982-44F16123F9AC(a)microsoft.com...

The only thing that comes to mind is if your program is manifested and calls
InitCommonControls(Ex) to utilize the version 6 common controls. Maybe
something there has changed regarding the transparent background. I seem to
recall some difference in behavior between UNICODE and ANSI apps regarding
this, but do not recall the details. If you learn more, please report here.

Thanks,
David

On Friday, February 15, 2008 9:57 AM
David Ching wrote:

Re: transparent CheckBox/radioBox
Great, thanks for updating us!

-- David

On Saturday, February 16, 2008 4:57 AM
jacadcap wrote:

Re: transparent CheckBox/radioBox
On 12 Lut, 16:37, "David Ching" <d...(a)remove-this.dcsoft.com> wrote:

Hi,

the solution that works for me in Unicode mode is drawing the
background in the CtlColor implementation of your class AND returning
a HOLLOW_BRUSH. You don't need to do anything in OnEraseBkgnd in that
case.

Jacek

On Wednesday, February 20, 2008 3:34 PM
Dn wrote:

Re: transparent CheckBox/radioBox
"David Ching" wrote:

investigating the manifest file, seems that the unicode project utilize
version 6 common control while non-unicode don't. could you please tel me
how to unutilize version6 common control?

thanks

On Wednesday, February 20, 2008 8:11 PM
Dn wrote:

David...thanks to your reply that really got to the point.
David...

thanks to your reply that really got to the point. I just resolved my
problem :)
my project was manifested and utilized version 6 common control when i
called InitCommonControls().
what i do then is using my own manifest file (instead of let the project
generate one for me) for creating and embedding the final manifest.

Thanks
Dana

"D(a)na" wrote:

On Thursday, February 21, 2008 12:27 AM
David Ching wrote:

Re: transparent CheckBox/radioBox
I am very glad to hear that, Dana! :-) Thanks for letting us know.

-- David


Submitted via EggHeadCafe - Software Developer Portal of Choice
WPF Report Engine, Part 4
http://www.eggheadcafe.com/tutorials/aspnet/5ac799db-385f-431a-8a45-8b37cb7f3186/wpf-report-engine-part-4.aspx