Option Compare Database
Option Explicit
Private Declare Function SetFocus Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowPlacement Lib "user32" ( _
ByVal hWnd As Long, _
lpwndpl As WINDOWPLACEMENT) _
As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWNOACTIVATE = 4
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9
[COLOR="SeaGreen"]'// set focus to window[/COLOR]
Public Sub Focus(hWnd As Long)
SetFocus (hWnd)
End Sub
[COLOR="seagreen"]'// check window minimized state[/COLOR]
Public Function Minimized(hWnd As Long) As Boolean
Dim wndPl As WINDOWPLACEMENT
Dim lngRetVal As Long
lngRetVal = GetWindowPlacement(hWnd, wndPl)
If (wndPl.showCmd = SW_SHOWMINIMIZED) Then
Minimized = True
End If
End Function
[COLOR="seagreen"]'// check window maximized state[/COLOR]
Public Function Maximize(hWnd As Long) As Boolean
Dim wndPl As WINDOWPLACEMENT
Dim lngRetVal As Long
lngRetVal = GetWindowPlacement(hWnd, wndPl)
If (wndPl.showCmd = SW_SHOWMAXIMIZED) Then
Maximize = True
End If
End Function
[COLOR="seagreen"]'// check window normal state[/COLOR]
Public Function Normal(hWnd As Long) As Boolean
Dim wndPl As WINDOWPLACEMENT
Dim lngRetVal As Long
lngRetVal = GetWindowPlacement(hWnd, wndPl)
If (wndPl.showCmd = SW_SHOWNORMAL) Then
Normal = True
End If
End Function