First, sorry if I sound arrogant/rude here.
All right, so everyone has run into this by now (I hope); I just haven't found any adequate answer anywhere. We start with a Common Controls 6 manifest and
case WM_CTLCOLORSTATIC:
if (/* window has WS_EX_TRANSPARENT */) {
SetBkMode((HDC) wParam, TRANSPARENT);
return (LRESULT) GetStockObject(HOLLOW_BRUSH);
}
and give our labels WS_EX_TRANSPARENT
. They become transparent; so far so good. Now we have to add that style to our checkboxes (because checkboxes respond to that and not to WM_CTLCOLORBTN
for some reason). And... the checkboxes become black!
Is there any way to make them fully transparent without resorting to owner draw? I'd rather not draw the checkboxes myself; I'd rather not have to guess whether it looks right or what the sizes are should the theming API fail on me (and I'm going to have to draw check boxes by themselves in the future when I add custom checkboxes to my list views and I'm already not happy with the amount of guessing involved).
These checkboxes are being drawn over a themed tab control. So far, I've found five dialogs in Windows XP with transparent checkboxes on themed tabs: General tab of Shortcut Properties, Taskbar tab of Taskbar and Start Menu Properties, System Restore tab of System Properties, General tab of Folder Options (radio buttons), and Keyboard tab of Accessibility Options. So this certainly must be possible! I'm sure the Windows UI authors didn't have to use custom draw throughout the OS... What are we all missing?
If I need to subclass that's fine (I already have a subclass anyway for event handling purposes), but I still would rather not have to draw myself.
As a bonus, what about push buttons? Overriding WM_CTLCOLORBTN
gives buttons a black border, but I do notice that none of the standard dialogs mentioned above bother to make the corners of buttons transparent, so eh :/
Thanks!
This answer is late, but offers a simpler approach.
To make a GroupBox's children transparent, process the WM_CTLCOLORBTN message in the GroupBox's subclass proc.
To make a GroupBox's title transparent, process the WM_CTLCOLORBTN message in the parent of the GroupBox's wndproc procedure.
Here is the link showing where I learned how.
My code (need this in both the groupbox's parent and in the groupbox's subclass proc):