July 12th, 2004, 10:57 AM
Modeless dialog which halts program execution....
I need to make a modeless dialog which halts the program, just like a modal dialog does. It's basically like a debugging dialog which will display messages. I want to keep it up, so that there is a history, but after every message I want to wait for them to hit a button, say a "Continue" button or something like that.
Anyone have any ideas on how I should go about this. I'm not looking for you to code it for me, just some suggestions and maybe a pointer or two.
July 12th, 2004, 11:04 AM
Some sort of loop that checks a return code & only continues when something = True? Not the most elegant, but pretty simple...!
Create a new form, put 2 objects on it, txtError (text box) and cmdContinue (command button), paste the following code into the forms module...
edit: this doesn't make it 'modal', user could still click elsewhere....you could maybe limit mouse movement to the form being displayed....?
Private m_bOKClicked As Boolean
Private Sub Form_Load()
'// Reset flag
m_bOKClicked = False
Private Sub cmdContinue_Click()
m_bOKClicked = True
Private Sub LoadMessage()
'// Get your message to display here....
Me.txtError = "Blah Blah Blah Happened..."
'// Show form before enter loop...
Me.Visible = True
Do Until m_bOKClicked
MsgBox "Error Was processed, form can now unload!"
Last edited by Dmorley; July 12th, 2004 at 11:07 AM.
July 12th, 2004, 12:04 PM
Or I guess another way to think of it is to have a Modal dialog which can start the program execution again when a button is clicked, but doesn't hide or unload my dialog
July 12th, 2004, 02:32 PM
I tried your code, or a variation on it. The problemis that DoEvents causes the CPU to hit 100%. Is there another, slightly better approach to this???
July 12th, 2004, 03:40 PM
Add a Sleep API call before or after the doevents statement.
The doEvents Statement will allow you program to receive messages, however, since you are in a tight loop, the processor will be pegged.
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
That should do it.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.