Title | Make a "semi-modal dialog" that acts modal with respect to a single form in an application |
Keywords | semi-modal, modal, dialog |
Categories | Software 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
|
|
|
|