Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I determine if a form is opened in dialog mode?

Status
Not open for further replies.

FancyPrairie

Programmer
Oct 16, 2001
2,917
US
Is there a way to know if the form was opened with the windowmode set as dialog? I know when you open a form with the windowmode set to dialog the popup and modal properties are set to true. However, if the modal property is set to false in design view, the value remains false at runtime even though the form was opened in dialog mode. The way the code is written, I can't pass a flag via the openargs to let me know how the form was opened.

Is there a way to tell if the windowmode of the open form method was set to acdialog?
 
in the forms on load event
Code:
Private Sub Form_Load()
  MsgBox IsDialog(Me)
End Sub
In a standard module.
Code:
Private Declare Function apiGetParent _
               Lib "User32" Alias "GetParent" (ByVal hWnd As Long) As Long

Public Function IsDialog(f As Form) As Boolean
  Dim lngParentHWnd As Long
  lngParentHWnd = apiGetParent(f.hWnd)
  If lngParentHWnd = hWndAccessApp Then
     IsDialog = True
  Else
     IsDialog = False
  End If
End Function

There is no way to check externally because code execution stops from the calling form/module until the form is closed or hidden. This assumes the form is not popup
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top