I don't know of any way to use the WIN32 API to capture the Restore/Maximize Event. The best workaround I can think of is to use the Win32 API in conjunction with the Timer event of a form that is always open (either the Main Menu or some hidden form) and periodically poll the main access window to determine whether it's currently maximized.
Enum WindowSize
wsMax = 1
wsMin
wsRestore
End Enum
'Functions return 1 for true and 0 for false; multiply result by -1 to use as Boolean'
Private Declare Function IsZoomed Lib "User32" (ByVal hWnd As Long) As Integer
Private Declare Function IsIconic Lib "User32" (ByVal hWnd As Long) As Integer
Function IsMaximized(hWnd As Long) As Boolean
IsMaximized = IsZoomed(hWnd) * -1
End Function
Function IsMinimized(hWnd As Long) As Boolean
IsMinimized = IsIconic(hWnd) * -1
End Function
Private Sub Form_Timer()
Static PrevWinSize As WindowSize
If IsMaximized(hWndAccessApp) Then
If PrevWinSize <> wsMax Then
'Window has been maximized since we last checked'
MsgBox "Main Access window is maximized"
PrevWinSize = wsMax
End If
ElseIf IsMinimized(hWndAccessApp) Then
If PrevWinSize <> wsMin Then
'Window has been minimized since we last checked'
MsgBox "Main Access window is minimized"
PrevWinSize = wsMin
End If
Else
If PrevWinSize <> wsRestore Then
'Window has been restored since we last checked'
MsgBox "Main Access window is restored"
PrevWinSize = wsRestore
End If
End If
End Sub
You'll need to set an interval in the form's TimerInterval property to control how frequently you need to poll the window size.
EDIT: Obviously you'll want to keep track of the main window's previous state so that you don't do any unnecessary processing. The code as posted reflects this.