This should probably be a quick solution - please help me.
I have successfully gotten transparent background for my CButton class with either
1) return 1 in OnEraseBackground()
2)
Code:
filtering out CButton in OnCtlColor
else if (nCtlColor == CTLCOLOR_BTN)
{
HBRUSH hbr = (HBRUSH)GetStockObject( HOLLOW_BRUSH );
pDC->SetBkMode( TRANSPARENT );
return hbr;
}
That is all good until I realized that the tabbing is screwed with the transparent background of mine.
Normally with 2 buttons, it should toggle between the two with the combinations of:
10 (button1 on focus, button 2 is not)
01 (button1 not focus, button 2 is )
However, now it becomes the following, in another word, there are 2 extra combinations, and I know SetFocus is tabbed to the right button since it invokes the right actions, but the button is just not drawn correctly.
00 (both are not on focus) -> extra !!
10 (button1 on focus, button 2 is not)
11 (both buttons on focus) -> extra
01 (button1 not focus, button 2 is )
I need the transparent background since it is gradient. I have tried the following code and the combination is right:
Why is there 2 extra combinations and how does the window clear and re-draw the background after 4 cycles. I would imagine that it wouldn't. Clearly I am clueless.
Thank you for your reply, sorry that I haven't had a chance to post what I meant.
Please see the attached exe for what I meant and the source files to test it out.
Yes, I want to do owner draw, but since the background dialog contains a bitmap, I want a transparent button, so the button is not going to be fancy but just owner draw.
The article on CButtonST v3.9 (MFC Flat buttons) is more suitable to my need since it is also transparent; howerver, it doesn't address tabbing, or I can't tab into it.
Thank you for getting back.
How should I do that to draw the rect twice? I have tried to put that
"DrawFocusRect(lpDIS->hDC, (LPRECT)&focusRect);"
in DrawItem() but it is not working. Please tell me more specific.
In addition, I have looked into the link you sent about the flat buttons, this clears the background by including PaintBk(), as a different approach, I thought I'd let you know.
PS: Do you happen to know, or someone, how to bypass the black background checkbox seen when using XP theme background with setting the background to transparent?
PS: For the checkbox being black, there are 2 solutions, one is bitblt and another is to call EnableThemeDialogTexture. I tried the first one and it works.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.