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 "semi-modal dialog" that acts modal with respect to a single form in an application
Keywordssemi-modal, modal, dialog
CategoriesSoftware Engineering
 
Give the dialog a Public variable MyMainForm. Then have the main form display the dialog like this:
 
Private Sub Command1_Click()
Dim dlg As New ActionDialog

    dlg.Caption = "Dialog for " & Me.Caption
    Set dlg.MyMainForm = Me
    dlg.Move _
        Me.Left + (Me.Width - dlg.Width) / 2, _
        Me.Top + (Me.Height - dlg.Height) / 2
    Me.Enabled = False
    dlg.Show vbModeless, Me
End Sub
 
This displays the dialog with the main form as the dialog's parent (so the dialog stays on top) and disables the main form (but not the other main forms).

Then in for dialog's Unload event handler, reenable the main form like this:

 
' Reenable the main form that displayed this form.
Private Sub Form_Unload(Cancel As Integer)
    MyMainForm.Enabled = True
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated