|
|
Title | Make a form act modal when it is not |
Keywords | form, modal, fake modal, dialog |
Categories | Controls, Tips and Tricks, Software Engineering |
|
|
In some cases, you may want to display a non-modal form while a modal form is visible. Unfortunately that's not possible. Instead you can use this trick to make a form seem modal when it isn't.
Disable the first form before displaying the second. Use a DoEvents loop
to process events while the second form is visible.
Note that this use of DoEvents may cause problems in some circumstances.
|
|
Private Sub Command1_Click()
Form2.Show
Enabled = False
Do While Form2.Visible
DoEvents
Loop
Unload Form2
Enabled = True
SetFocus
End Sub
|
|
|
|
|
|