
Originally Posted by
Ritzky
This code works great other than the fact that it doesn't restore the window if it's minimized. How can I have it restore the minimized window IF IT'S minimized.
One simple way is to use the IsIconic API to test if a window is minimized, theres also the IsZoomed to tell you if the window is maximized, and if its not either then its in a normal windowstate.
Example..., (see pauls code for ShowWindow)
Code:
<DllImport("user32.dll")> _
Private Shared Function IsZoomed(hWnd As IntPtr) As Boolean
End Function
Private Declare Auto Function IsIconic Lib "user32.dll" (ByVal hwnd As IntPtr) As Boolean
Window = FindWindow(Nothing, WindowName)
' Always make sure you have a vaild window handle before calling APIs!
If Not Window.Equals(IntPtr.Zero) Then
' Restore window if minimized
If IsIconic(Window) Then
ShowWindow(Window, SW_RESTORE)
End If
End If