ID Number: Q77316
1.00
WINDOWS
Summary:
The Show method in the Visual Basic language can display a form either
as modal or modeless. No direct support exists in the language to
determine the display state of the form without maintaining global
variables that contain the display state of the form. However, the
Windows API function GetWindowLong can be used to check the display
state of the form.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Widows.
More Information:
When Visual Basic displays a modal form (.Show 1), all other forms
will be modified to contain the Window Style WS_DISABLED. The Windows
API function GetWindowLong can be used to return the Window Style of
another form to check for the WS_DISABLED style.
The following code demonstrates this process:
Global.Bas
----------
DefInt A-Z
Global Const GWL_STYLE = (-16)
Global Const WS_DISABLED = &H8000000
Declare Function GetWindowLong& Lib "user" (ByVal hWnd, ByVal nIndex)
Form1.Frm
---------
Sub Form_Click ()
'Flip between "Modeless" and "Modal" display states
Static ShowStyle
Unload form2
form2.Show
ShowStyle ShowStyle = (ShowStyle + 1) Mod 2
End Sub
Form2.Frm
---------
Sub Form_Paint ()
'Get the Window Style for Form1
WinStyle& = GetWindowLong(Form1.hWnd, GWL_STYLE)
If WinStyle& And WS_DISABLED Then
'The WS_DISABLED style is set on "FORM1" when "FORM2"
'is displayed with the Modal flag (Show 1)
Print "Modal - Show 1"
Else
'The WS_DISABLED style is not set on "FORM1" when "FORM2"
'is displayed with the Modeless flag (Show or Show 0)
Print "Modeless - Show"
End If
End Sub
Additional reference words: 1.00