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!
WS_EX_TRANSPARENT
is not the way. – CynosureWS_EX_TRANSPARENT
, which tells the window manager not to draw until parent windows have drawn, and return the hollow brush from theWM_CTLCOLORxxx
messages, that the controls will draw with the hollow brush, which draws nothing, and thus shows the contents below. Where is this breaking? – DestructWM_CTLCOLORSTATIC
properly, in which case is there anything else I can do to avoid having to draw a background myself? I triedcase WM_ERASEKGND: return 1;
in the subclass and callingSetBkMode()
there, both to no effect. – DestructWM_PRINTCLIENT
in your parent's handler, that helped me in the past. The point is to copy your drawing code from theWM_PAINT
except you have nowHDC
provided aswParam
of the message (HDC hdc = (HDC)wParam
instead ofHDC hdc = BeginPaint
and you don't needEndPaint
). As for checkbox, I guess you will need to custom draw it as I don't know any other solution... – NarikoDefWindowProc()
responses :S – Destruct