Click to See Complete Forum and Search --> : Dialogs - using multiple windows


MoeRahn
April 20th, 1999, 10:44 AM
I have been working on a simple timer for my first delve into VC++ and the MFC. My choice to start with a timer was based on the needs of a co-worker - she's taking a typing class and needs a timer that 1) gives a 5-second countdown for her to get her hands in place, and 2) remains on top, so she can see the clock as she's typing into WP on her 640x480 display.

The timer itself works ( binary & code: http://www.ci.saint-paul.mn.us/webmaster/pete/timer042099.tgz ), but I can't seem to pop open a 'Set Time' dialog box. Basically, when the 'set' button is pressed on the main dialog window, I need a new dialog box to appear, and the previous dialog box to waitpid or whatever for the return from the Set Time dialog.

I've tried creating the 2nd dialog in the main app, and setting it hidden - didn't like that. I tried creating the 2nd dialog when the 'Set' button is pressed - doesn't have the right access to call it there.

If anyone has any ideas of how to pull this off, I'd love to hear them.

The Software said "Windows 95 or Better",
So I installed Linux

Paul McKenzie
April 20th, 1999, 12:29 PM
If your goal was to communicate with the parent while the second dialog is displayed, you shouldn't be doing this by invoking a modal dialog.

This is probably what's happening in the program (or something similar):

The problem is that for a modal dialog, it's parent's message queue is halted until the dialog is disposed of. You have a timer set, but the main dialog's message queue becomes blocked and can't process the timer messages when the secondary modal dialog is displayed. This probably screws up the messaging, and you get all sorts of problems.

Modal dialogs were meant to process independent of the parent, since the parent can't do anything (even get its own messages) until the dialog is closed. This is enforced in a modal dialog since modal dialogs have their own private message queues that are run instead of the parent's message queue.

You should either stop the timer before invoking the dialog, or use modeless dialog boxes, or possibly integrate the controls from the "set" dialog into the main dialog.

Regards,

Paul McKenzie

MoeRahn
April 20th, 1999, 12:43 PM
I used 'modal' so I could get it to stay on top, not really for message processing (probably my first mistake). So how do I get the dialog to always float on top?

The plan was, when the timer is running, the 'Set' button is disabled. So you have to pause the timer before setting it. When the 'Set Timer' dialog is dismissed, it would either pass int nMinutes, or int nMinutes & int nCountdown if 'OK' was pressed, or nothing on a cancel.

There must be another way to set a CWnd object always on top. Do you happen to know what it is?

The Software said "Windows 95 or Better",
So I installed Linux

Paul McKenzie
April 20th, 1999, 01:05 PM
Try CWnd::SetWindowPos(HWND_TOPMOST,...) or the API SetWindowPos(hWnd, HWND_TOPMOST,...)

Regards,

Paul McKenzie