Showing modeless dialog from modal dialog

Showing modeless dialog from modal dialog

Post by Carl Colij » Wed, 01 Jan 2003 03:41:58



Hi all,

My program shows a modal dialog box.  From within this dialog box I want to
show a modeless dialog box when the user presses a button in the modal box
(that behaves independant from the modal dialog box).  The goal is to have
the modeless dialog remain present when the modal dialog exits.

First try was to just show the dialog in my button handler, but then the
modeless dialog would be killed when the modal dialog would exit (even
without proper notification from WM_DESTROY etc).  I presume this is because
the modeless dialog's messages got pumped by the modal box's pump, and on
termination of that pump, all subsequent messages get lost => exit modeless
dialog.

Second try was to let the modeless dialog have it's own separate message
pump in a separate thread, so it wouldn't intermingle with the modal box's
pump.  So now, I start up a new thread in my button handler, and the thread
will Create the dialog and then pump the messages in this thread's own
message pump (that only scans for the correct HWND, by the way).  Looks
cool, should work (at least a bit better than try # 1), but failed.  This
time, the Create routine doesn't return untill the modal dialog is
terminated; after that, all continues as planned.

Of course I do not want the modeless dialog to appear after the user has
killed the modal dialog.  Does anyone have any ideas as to how to solve this
problem?  The stuff I'm working with is:
- Modeless dialog logic works on it's own when not triggered from the modal
dialog
- Modal dialog shown by DoModal method in class derived from ATL's
CDialogImpl
- Modal dialog ultimately operated by a call to DialogBoxParam
- Modeless dialog's message queue created before the call to Create with a
call to PeekMessage
- ATL out-of-process exe server (= another message pump present at global
level for COM stuff)

Thanks in advance,
Carl Colijn

Sidenote: my news provider (Chello from UPC) thinks 600TB of newgroup
binaries is more important than 100KB of other proper newsgroup posts =>
messages will stay on the news server for 1-2 day on average, so I might not
be able to respond to this post, or respond with great delay via Google...

 
 
 

1. Modal dialog as the parent of a modeless dialog...

Hi,

I'm using a third party activex control in my MDI application. I think
it is written in MFC and of composite type.  It is kind of an editor,
the control has to be created only once and whenever needed it should
be shown
in a modal dialog box.  

Though I'm not very sure, if this is the "correct" implementation, I
did
like this:

The control needs a parent window, so at the application start up,
I create a modeless dialog and creates the control specifying modeless
dialog as its parent and hide the dialog.

While working inside a MDI child window, when the user requests,  a
modal dialog is created (with parent as the CMDIChildWnd) and the
modeless
dialog is made child of of modal dialog & placed inside and shown.
Once the interaction is done, the modeless dialog is hidden.

The hierarchy is like this:
Parent of control is modeless dialog
Parent of modeless dialog is modal dialog
Parent of modal dialog is the CMDIChildWnd.

I'm facing some problems with this implementation, as always, while
handling modal & modeless dialog boxes together.  

1) Though I'm setting the parent of the modeless dialog, its not set.
The GetParent() still returns the mainframe.

2) The keyboard messages are not processed by the control, unless I
return
a FALSE in CMDIChildWnd

3) Keyboard accelerator messages are not received by the modal dialog.
 They
   can be received by the CMDIChildWnd.

I hope my explanation is clear, if not pls let me know.

Any ideas on what's happening?  Also any thoughts on a possible "good
design" would be appreciated.

Thanks in advance for your time.

Regards,
Vith.

2. Q: Btrieve driver for excel

3. Can we change the Modal Dialog to Modeless dialog ???

4. Apple Laserwriter II NT & win95

5. Modeless dialog out of a Modal dialog box: possible?

6. JavaError in Transfer

7. Modeless dialog inside modal dialog

8. Computer City - Best Data Kflex 56FW-VW PCI modem - V.90 or not???

9. Modal dialog doesn't disable modeless dialog when running InPlace.

10. Calling a modeless dialog box from a modal dialog box

11. REPOST: Modal dialog doesn't disable modeless dialog when running

12. Modeless Dialog in another modeless Dialog

13. Help! Modal dialog opening modal dialog = problem