CDialog & DLL

Started by
1 comment, last by bschwagg 19 years, 8 months ago
Here's a question that's been absolutely haunting me for a week now, which I'm sure a bunch of guru people have already solved somewhere... I have an Excel Add-In (it's a DLL) that pops up modal CDialog boxes. When I ShowWindow(WS_HIDE) one dialog box and open another, excel gets minimized. I want excel to always be the top window with the dialogs on top of it. How could I set up the CDialog's so they're created under the same window/frame as excel? Right now the styles are set to "pop-up" and I've created the parent CWnd as NULL. I've tried using a overlapped, invisible frame with the dialogs as parents. I've tried using AfxGetMainFrame(). I've tried to set WS_VISIBLE and repaint the window, but it leaves portions of the old dialog as artifacts. Nothing works. Anyone have other ideas?
cha cha cha
Advertisement
I think you'd want to make the dialogs modal to Excel's main window. The only problem is getting a handle to it. Unfortunately, I'm not aware of any methods in Excel's object model that return the HWND directly.

But I think you can get the title of the active window, and then use FindWindow to get its handle. Alternatively, you could use EnumWindows to enumerate the top-level windows, checking for windows that belong to the current process, and have the correct title.
I found a solution!
http://www.codeproject.com/dialog/notmodaldialogs.asp

"If you have two or more MFC modal dialogs which have the same parent window, then the moment you dismiss any one of those modal dialogs, all the other modal dialogs will lose their modality because now the parent window has been re-enabled."

The workaround is overrideing the ON_OK and OK_CANCEL messages, now I just have to figure out how to do this.
cha cha cha

This topic is closed to new replies.

Advertisement