Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleMake a form act modal when it is not
Keywordsform, modal, fake modal, dialog
CategoriesControls, 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated