GUI Panels

Hey so for a GUI I'm designing I came up with an idea of having the main window then sort of a container panel which would hold all of the other widgets. I'm using a static window for the panels and I'm not at all happy with how it's turning out. It has a gray background color even when when I set the window style to WS_EX_TRANSPARENT and I set the background color to Transparent in WM_PAINT using SetBkMode(hdc, TRANSPARENT). Basically what I want to be able to do is have a solid window as the frame, transparent window as the panels, and solid windows as the widgets.


Here's a basic picture of what I am trying to accomplish:

1
2
3
4
5
6
7
 ______________________
|         FRAME        |
| ____________________ |
||         PANEL      ||
|| WIDGET      WIDGET ||
||____________________||
|______________________|


I've searched around and I can't seem to find anything on how to properly do this. Reason that I want to do this is because I feel as though this is a lot more structured/better organized and will be able to be easily expandable upon. Each window component has its own class and within their class they contain a vector of the other components they contain. So my Frame class has a vector of all the panels contains and the panel class has a vector of all the widgets it contains.

Thank you in advance!
Have a look at this:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb787524%28v=vs.85%29.aspx

Perhaps if you handle that message and return a null brush it will make the static control transparent...

return (LONG_PTR)GetStockObject(NULL_BRUSH);

My other idea was to make the panel a popup layered window, but apparently layered child windows are only supported in Windows 8.

Come to think of it, using a window for the panel seems kind of superfluous. It is already a control container. So in place of a window you could get by with a RECT to define the area in which the contained controls are aligned.
Last edited on
WM_CTLCONTROLSTATIC is send to the parent, not to the control itself, beware!. You can make the background transparent like this:
1
2
3
4
5
6
7
8
9
10
11
12
//make background transparent
            case WM_CTLCOLORSTATIC:
            {
                HDC hDC = (HDC)wParam;

                SetBkMode(hDC, TRANSPARENT);
                SetTextColor(hDC, RGB(0, 0, 0)); //text color black

                MessageBoxW(NULL, L"WM_CTLCOLORSTATIC", L"Error!",MB_ICONEXCLAMATION|MB_OK);

                return (LRESULT)GetStockObject(NULL_BRUSH);
            }
Come to think of it, using a window for the panel seems kind of superfluous. It is already a control container. So in place of a window you could get by with a RECT to define the area in which the contained controls are aligned.

That's actually a great idea. Not sure how that slipped past me. Nonetheless, thank you both for the help!
you might want to give ''qt'' a try.

especially the things you plan to do are really easy with it's designer.
Registered users can post here. Sign in or register to post.