Article ID: 110620
Article Last Modified on 10/29/2003
Type RECT
left As Integer
top As Integer
right As Integer
bottom As Integer
End Type
Type POINTAPI
x As Integer
y As Integer
End Type
Type WINDOWPLACEMENT
length As Integer
flags As Integer
showCmd As Integer
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Global Const WPF_RESTORETOMAXIMIZED = &H0002
' Enter the following Declare statement as one, single line:
Declare Function GetWindowPlacement Lib "User"
(ByVal hWnd As Integer, lpwndpl As WINDOWPLACEMENT) As Integer
Function is_max (hWnd As Integer) As Integer
Dim wp As WINDOWPLACEMENT
Dim rtn As Integer
wp.length = Len(wp) ' Initialize size
rtn = GetWindowPlacement(hWnd, wp)
If wp.flags = WPF_RESTORETOMAXIMIZED Then
is_max = True
Else
is_max = False
End If
End FunctionNOTE: The value of wp.length must be initialized or the call to
GetWindowPlacement will return an error. There is no mention of this in
the Microsoft Windows "Programmer[ASCII 146]s Reference," but it is described as
a documentation error in the following article in the Microsoft
Knowledge Base:
89569 DOCERR: GetWindowPlacement Function Always Returns an Error
Sub Command1_Click ()
If is_max((Form2.hWnd)) Then
Label1.Caption = "Form 2 will be Maximized"
Else
Label1.Caption = "Form 2 will be Normalized"
End If
End SubNOTE: Form2.hWnd cannot be passed directly to a function as a parameter.
It must be enclosed in an extra set of parentheses or stored in a
temporary variable.Additional query words: 3.00
Keywords: KB110620