-
July 12th, 2004, 10:57 AM
#1
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
#2
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....?
Code:
Option Explicit
Private m_bOKClicked As Boolean
Private Sub Form_Load()
'// Reset flag
m_bOKClicked = False
Call LoadMessage
End Sub
Private Sub cmdContinue_Click()
m_bOKClicked = True
End Sub
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
DoEvents
Loop
MsgBox "Error Was processed, form can now unload!"
End Sub
Last edited by Dmorley; July 12th, 2004 at 11:07 AM.
-
July 12th, 2004, 12:04 PM
#3
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
#4
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
#5
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)
Do
Sleep 100
DoEvents
Loop
That should do it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|