0
votes

I am working on designing a relatively heavy app for windows that will work in multiple windows (each can be in docked/undocked modes).

So far, the development of the app has been done in the Win32 framework but it feels like that the look of the app cannot be modernized further than a certain limit.

We, specifically have a problem adding menu items to children windows when they are in docked mode. They can have the menu items but they will look weird with a blue windows-XP style frame when they become children in docked mode.

Is there a way to remove this blue frame and also close, maximize/minimize buttons but keep the menubar for children's windows in Win32 API?

This is the minimal code of how I am making a window a child window:

ShowWindow(hParentWindow, SW_SHOWNORMAL);
SetParent(hChildWindow, hParentWindow);
MoveWindow(hChildWindow, 0, 0, width2, length2, true); //Moving Child window inside the parent        
RedrawWindow(hChildWindow, nullptr, nullptr, RDW_INVALIDATE);
ShowWindow(hChildWindow, SW_SHOWNORMAL);

This way I will have the menu bar in the child window but it will also have the blueish frame and close maximize that I dont want. If I change the style of the child window with the following code, it will no longer have the bluish frame but it will also lose its menubar:

SetWindowLong(hChildWindow, GWL_STYLE,  CHILD_STYLES);

image

enter image description here

1
You cannot assign a menu to a child window. Whatever you are doing does not match your description. Please show a minimal reproducible example. - IInspectable
I added a picture that the child window still has the menu bars. It just looks weird with that blue frame that I cannot get rid of. - Kaveh
Again, please show a minimal reproducible example. And since you skipped over it, please take the tour. Also make sure to read How to Ask. - IInspectable
added some reproducible codes. Hope it makes it clearer. - Kaveh
WS_CHILD - The window is a child window. A window with this style cannot have a menu bar. And SetParent does not modify the window styles of the window whose parent is being changed. If hWndNewParent is not NULL set the WS_CHILD style before calling SetParent. - Rita Han

1 Answers

0
votes

Your windows have a frame when not being docked. You must remove the frame by using a combination of GetWindowLong() AND SetWindowLong()

Example:

LONG lExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
LONG lStyle = GetWindowLong(hwnd, GWL_STYLE);

lStyle &= ~(WS_BORDER | WS_CAPTION);
lExStye &= ~(WS_EX_MDICHILD | WS_EX_OVERLAPPEDWINDOW);

SetWindowLong(hwnd, GWL_EXSTYLE, lExStyle);
SetWindowLong(hwnd, GWL_STYLE, lStyle);

The flags depend of course on the effect you want, and this form of sequence should be done when undocking as well, using bitwise AND and OR to set/reset flags.

The 'blue frame' is indicative of an MDI child windows, or an overlapped window being the child of a child window.