Link to home
Start Free TrialLog in
Avatar of Mark Joy
Mark Joy

asked on

Can't click on controls/menu when detach MDI child out of MDI client area

Whole sample project can be found here: Sample project

Normal MDI child:
User generated image
MDI child is detached out of MDI client area:
User generated image
Problem is after MDI child is detached, I am not able to click on menu/controls anymore.

I think one approach is to subclass winproc of MDI app, and then catching the messages and redirect them (like this one). But I dont know where to begin.

Any idea/ other approaches are welcome!

The code I used to detach MDI child:

HWND MDIHwnd = pMainFrame->m_hWndMDIClient;
HWND mdiChildHwnd = GetWindow(MDIHwnd, GW_CHILD);

unsigned int style = GetWindowLongPtr(mdiChildHwnd, GWL_STYLE);
style = (style & (~WS_CHILD) | WS_POPUP);
SetWindowLongPtr(mdiChildHwnd, GWL_STYLE, style);

WaitForInputIdle(mdiChildHwnd, INFINITE);
SetParent(mdiChildHwnd, NULL);

WaitForInputIdle(mdiChildHwnd, INFINITE);
SetWindowLongPtr(mdiChildHwnd, GWLP_HWNDPARENT, (long)MDIHwnd);

Open in new window

Avatar of sarabande
sarabande
Flag of Luxembourg image

if the window you called mdi child is derived from class CMDIChildWnd, then you can't make it to a popup window. a CMDIChildWnd is derived from CFrameWnd and therefore is a frame which is one of the triple frame, document, view that handles one document type of MDI (multiple document Interface). by making it a popup the CMainFrm class nolonger can support toolbar, menus and outer frame for all the child frames derived from CMDIChildWnd.

if you tell your requirements we probably could make suggestions how you could use a view as a popup-like window fo rthose purposes.

Sara
ASKER CERTIFIED SOLUTION
Avatar of Mark Joy
Mark Joy

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
since you seem to be happy with this, i don't want object. however, it is rarely a good idea to overrule a high-level architecture (as it is with the mdi framework) by low-level message handling.

Sara
Avatar of Mark Joy
Mark Joy

ASKER

Thank you for your comment.
Well, it is working without any problem. As I said, I don't have the source code of the MDI app, but I need to move its MDI child out of its MDI client area. Now if you have a better solution, I'm more happy to hear it out.
accepted answer