[Resolved] Show window as modal dialog
Is there a way to display a client window created with CreateWindowEx(...) as a modal dialog, other than calling DialogBox(...)?
Ex:
A client window is created with CreateWindowEx and HWND_DESKTOP is specified as the parent. Then, another client is created with CreateWindowEx and the first hWnd is specified as the last's parent. This keeps the child window always on top of the parent but still allows the parent to be manipulated.
I don't think there is a way other than using a Dialog Box.
Re: Show window as modal dialog
Sure there is: you just need to emulate DialogBox. In other words, disable the parent window.
Re: Show window as modal dialog
Quote:
Originally Posted by CornedBee
Sure there is: you just need to emulate DialogBox. In other words, disable the parent window.
Yeah, the closest I've gotten is calling GetClassInfoEx with the #32770 dialog box class and changing the WndProc and Class Name. Find the window styles with Spy++ calling CreateWindowEx with no luck. The window isn't shown.
Re: Show window as modal dialog
Huh? Just call EnableWindow on the parent window handle!
Also, search http://blogs.msdn.com/oldnewthing/
Re: Show window as modal dialog
Quote:
Originally Posted by CornedBee
Ok, so calling GetClassInfo to the dialog class was an admittedly bad idea I borrowed.
You're a lifesaver once again!
Re: [resolved]Show window as modal dialog
One more thing. I assume the DialogBox or CreateDialog calls centers the dialog behind the scenes after the call to CreateWindow if the style DS_CENTER is specified. DS_CENTER has no effect if specified in CreateWindow.
So will I need to do this manually?
Re: Show window as modal dialog
Probably, yeah. DS_CENTER, as the DS prefix says, is a dialog-specific style, so it's a good guess that DialogBox and CreateDialog are responsible for handling it. (Or perhaps the dialog default procedure.)