views:

93

answers:

1

I have an MDI app. I would like to add an icon to the non client title bar of the child window that allows the window to float separately from the parent MDI container, allowing the user to take the child windows and arbitrarily place them around the desktop, outside of the MDI window.

I have seen it done so I know it's possible, but I'm having a hard time figuring out how to accomplish it.

I am using WTL (Windows Template Library) however I'm tagging this with MFC and Win32 since I believe the underlying principles will be the same, and folks might have knowledge across the spectrum of Windows APIs.

+4  A: 

It's been a while since I did this, but I think it was sufficient to call SetParent (your_hwnd, 0) to let the window escape from it's parent.

The message passing will change a bit, so you may have to redirect some messages from the main-window to the former child window. This is most probably required if you want the main menu of your MDI Application to work with the ex-child.

If you get drawing problems you may have to change the window style using SetWindowLong.

Good choice to use WTL btw - in my oppinion a very nice API abstraction without any bells and whistles.

Nils Pipenbrinck