Article ID: 113881
Article Last Modified on 5/6/2003
Option Explicit
Declare Function GetActiveWindow Lib "User" () As Integer
Declare Function GetParent Lib "User" (ByVal hWnd As Integer) _
As Integer
Function GetAccesshWnd ()
Dim hWnd As Integer
Dim hWndAccess As Integer
' Get the handle to the currently active window.
hWnd = GetActiveWindow()
hWndAccess = hWnd
' Find the top window without a parent window.
While hWnd <> 0
hWndAccess = hWnd
hWnd = GetParent(hWnd)
Wend
GetAccesshWnd = hWndAccess
End Function
Declare Function ShowWindow% Lib "User" (ByVal hWnd%, _
ByVal nCmdShow%)
Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Function AccessMinimize()
AccessMinimize = ShowWindow(GetAccesshWnd(), SW_SHOWMINIMIZED)
End Function
Function AccessMaximize()
AccessMaximize = ShowWindow(GetAccesshWnd(), SW_MAXIMIZE)
End Function
Function AccessRestore()
AccessRestore = ShowWindow(GetAccesshWnd(), SW_SHOWNORMAL)
End Function
Declare Function IsIconic Lib "User" (ByVal hWnd As Integer) _
As Integer
Declare Function IsZoomed Lib "User" (ByVal hWnd As Integer) _
As Integer
Function IsAccessMaximized ()
If IsZoomed(GetAccesshWnd()) = 0 Then
IsAccessMaximized = False
Else
IsAccessMaximized = True
End If
End Function
Function IsAccessMinimized ()
If IsIconic(GetAccesshWnd()) = 0 Then
IsAccessMinimized = False
Else
IsAccessMinimized = True
End If
End Function
Function IsAccessRestored ()
If IsAccessMaximized() = False And _
IsAccessMinimized() = False Then
IsAccessRestored = True
Else
IsAccessRestored = False
End If
End Function
Declare Sub MoveWindow Lib "User" (ByVal hWnd As Integer, _
ByVal X As Integer, ByVal Y As Integer, _
ByVal nWidth As Integer, ByVal nHeight As Integer, _
ByVal bRepaint As Integer)
Function AccessMoveSize (iX As Integer, iY As Integer, _
iWidth As Integer, iHeight As Integer)
MoveWindow GetAccesshWnd(), iX, iY, iWidth, iHeight, True
End Function
Additional query words: hWnd hWindow hWin
Keywords: kbhowto kbprogramming KB113881