Hi,
I would like to find whether another application (third party application) is in which state?
Whether it is hidden or minimized or maximized or normal, etc.
Thanks in advance.
Printable View
Hi,
I would like to find whether another application (third party application) is in which state?
Whether it is hidden or minimized or maximized or normal, etc.
Thanks in advance.
There may be other ways, but this should work:
VB Code:
Private Type POINTAPI x As Long y As Long End Type Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type WINDOWPLACEMENT Length As Long flags As Long showCmd As Long ptMinPosition As POINTAPI ptMaxPosition As POINTAPI rcNormalPosition As RECT End Type Private Declare Function GetWindowPlacement Lib "user32" ( _ ByVal hWnd As Long, _ lpwndpl As WINDOWPLACEMENT) As Long Private Const SW_NORMAL As Long = 1 Private Const SW_MINIMIZE As Long = 6 Private Const SW_MAXIMIZE As Long = 3 Private Function GetWindowState(ByVal lhWnd As Long) As FormWindowStateConstants Dim winPLACE As WINDOWPLACEMENT winPLACE.Length = Len(winPLACE) GetWindowPlacement lhWnd, winPLACE Select Case winPLACE.showCmd Case SW_MINIMIZE GetWindowState = vbMinimized Case SW_MAXIMIZE GetWindowState = vbMaximized End Select End Function
Ok, I am a little late for this question, I know...
But it might help all, who find this thead via a web search. :)
Yes, the most simple way would probably to use following API functions:
Code:Private Declare Function IsZoomed Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Function IsIconic Lib "user32.dll" (ByVal hWnd As Long) As Long
Yet another way is by checking the Window Style bits:
Code:Private Const GWL_STYLE As Long = (-16&) 'Retrieves the window styles.
Private Const WS_MAXIMIZE As Long = &H1000000 'The window is initially maximized.
Private Const WS_MINIMIZE As Long = &H20000000 'The window is initially minimized.
Private Const WS_VISIBLE As Long = &H10000000 'The window is initially visible.
Private Declare Function GetWindowLongW Lib "user32.dll" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Function IsIconic(ByVal hWnd As Long) As Boolean
IsIconic = ((GetWindowLongW(hWnd, GWL_STYLE) And WS_MINIMIZE) = WS_MINIMIZE)
End Function
Private Function IsWindowVisible(ByVal hWnd As Long) As Boolean
IsWindowVisible = ((GetWindowLongW(hWnd, GWL_STYLE) And WS_VISIBLE) = WS_VISIBLE)
End Function
Private Function IsZoomed(ByVal hWnd As Long) As Boolean
IsZoomed = ((GetWindowLongW(hWnd, GWL_STYLE) And WS_MAXIMIZE) = WS_MAXIMIZE)
End Function