Article ID: 147214
Article Last Modified on 1/19/2007
Option Explicit
Declare Function apiGetActiveWindow Lib "user32" Alias _
"GetActiveWindow" () As Long
Declare Function apiGetParent Lib "user32" Alias "GetParent" _
(ByVal hwnd As Long) As Long
Function GetAccesshWnd ()
Dim hWnd As Long
Dim hWndAccess As Long
' Get the handle to the currently active window.
hWnd = apiGetActiveWindow()
hWndAccess = hWnd
' Find the top window without a parent window.
While hWnd <> 0
hWndAccess = hWnd
hWnd = apiGetParent(hWnd)
Wend
GetAccesshWnd = hWndAccess
End Function
? GetAccesshWnd()
Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
(ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Global Const SW_MAXIMIZE = 3
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Function AccessMinimize()
AccessMinimize = apiShowWindow(GetAccesshWnd(), SW_SHOWMINIMIZED)
End Function
Function AccessMaximize()
AccessMaximize = apiShowWindow(GetAccesshWnd(), SW_MAXIMIZE)
End Function
Function AccessRestore()
AccessRestore = apiShowWindow(GetAccesshWnd(), SW_SHOWNORMAL)
End Function
? <function name>()
-or-
<function name>
Declare Function apiIsIconic Lib "user32" Alias "IsIconic" (ByVal _
hwnd As Long) As Long
Declare Function apiIsZoomed Lib "user32" Alias "IsZoomed" (ByVal _
hwnd As Long) As Long
Function IsAccessMaximized ()
If apiIsZoomed(GetAccesshWnd()) = 0 Then
IsAccessMaximized = False
Else
IsAccessMaximized = True
End If
End Function
Function IsAccessMinimized ()
If apiIsIconic(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
? <function name>()
Declare Function apiMoveWindow Lib "user32" Alias "MoveWindow" _
(ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal _
nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) _
As Long
Function AccessMoveSize (iX As Integer, iY As Integer, iWidth As _
Integer, iHeight As Integer)
apiMoveWindow GetAccesshWnd(), iX, iY, iWidth, iHeight, True
End Function
? AccessMoveSize(0, 0, 640, 480)
113881 ACC: How to Retrieve the Microsoft Access Window Handle (1.x, 2.0)
Keywords: kbhowto kbprogramming KB147214