Control transparency
-
Hi everybody. I just can not set a transparency for the cation part of the group box control. The project is a standat Visual C++ windows application, no MFC, I use ATL for windows (CDialogImpl), but it should be the same as for any other project that does not include the MFC. So, I can intercept the message that paints the static controls, and make static controls transparent like this in OnCtlColorStatic: ::SetBkMode((HDC)wParam, TRANSPARENT); return (LRESULT) GetStockObject (HOLLOW_BRUSH); but how to do that for a group box control? The caption of it gets a weird gray color, and I just can not get rid off it. Thanks.
You have a handle to the DC, did you trying setting the text color on it?
-
You have a handle to the DC, did you trying setting the text color on it?
The handle is to the message that notifies that the static controls needs to be re-drawn, there is no such message for a group-box control. Anyways, messages in ATL are much more complex than those in MFC. I am currently playing with the atlcontrols.h that comes with the new ATL 8 and is supposed to wrap most of the control's functionality...if someone does not help me here in the meantime. :) Anyways, thanks for your reply. Sarajevo, Bosnia
-
The handle is to the message that notifies that the static controls needs to be re-drawn, there is no such message for a group-box control. Anyways, messages in ATL are much more complex than those in MFC. I am currently playing with the atlcontrols.h that comes with the new ATL 8 and is supposed to wrap most of the control's functionality...if someone does not help me here in the meantime. :) Anyways, thanks for your reply. Sarajevo, Bosnia
A groupbox control IS a static control, thats why the messages are the same.
-
A groupbox control IS a static control, thats why the messages are the same.
-
Hi everybody. I just can not set a transparency for the cation part of the group box control. The project is a standat Visual C++ windows application, no MFC, I use ATL for windows (CDialogImpl), but it should be the same as for any other project that does not include the MFC. So, I can intercept the message that paints the static controls, and make static controls transparent like this in OnCtlColorStatic: ::SetBkMode((HDC)wParam, TRANSPARENT); return (LRESULT) GetStockObject (HOLLOW_BRUSH); but how to do that for a group box control? The caption of it gets a weird gray color, and I just can not get rid off it. Thanks.
A group box is actually a button, so you need to handle
WM_CTLCOLORBTN
.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
damir_tk wrote:
...a group box control is a BUTTON control...
Indeed! ATL draws its own controls? It should be much easier to make transparent then. Making the Windows group box (BUTTON) control text transparent, OTOH, good luck!
-
A group box is actually a button, so you need to handle
WM_CTLCOLORBTN
.--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
-
Yup...I already know that, however the group box never receives the WM_PAINT message, even tho it is a button. One of those nice little things that makes us a true masochists programming in Visual C++. Thanks.
damir_tk wrote:
...however the group box never receives the WM_PAINT message...
Neat! When does it draw itself then?
-
damir_tk wrote:
...however the group box never receives the WM_PAINT message...
Neat! When does it draw itself then?
-
See this...he figured out the same strange behavior, and his code works for the MFC, will never work for the ATL: http://www.codeproject.com/miscctrl/tgroupbox.asp[^]
Thanks for the link. I looked at the code. I saw no "subclassing" going on besides what MFC already does for you. It is an owner drawn control implemented by overriding WM_PAINT and drawing the entire control instead of using the Windows ownerdraw interface. My point in previous posts is that no matter what wrapper you are using, if the control is a Windows control then aside from making an owner-drawn control, there's no way to magically change the way the control draws itself. Unfortunately, Microsoft chose to not fully implement transparency (via WS_EX_TRANSPARENT) in all controls and multi part controls like the group box that require more than one background brush do not work well with the WM_CTLCOLOR messages. I have no idea how ATL wraps a window, but if there's no way to intercept every message to the window then it sounds like a pretty lame wrapper. Even the lowly MFC lets you do that :)
-
Thanks for the link. I looked at the code. I saw no "subclassing" going on besides what MFC already does for you. It is an owner drawn control implemented by overriding WM_PAINT and drawing the entire control instead of using the Windows ownerdraw interface. My point in previous posts is that no matter what wrapper you are using, if the control is a Windows control then aside from making an owner-drawn control, there's no way to magically change the way the control draws itself. Unfortunately, Microsoft chose to not fully implement transparency (via WS_EX_TRANSPARENT) in all controls and multi part controls like the group box that require more than one background brush do not work well with the WM_CTLCOLOR messages. I have no idea how ATL wraps a window, but if there's no way to intercept every message to the window then it sounds like a pretty lame wrapper. Even the lowly MFC lets you do that :)
-
Oh, sorry for that, I stand corrected.