Results 1 to 17 of 17

Thread: [RESOLVED] hwnd help?

Threaded View

  1. #8
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: hwnd help?

    Quote Originally Posted by Ritzky View Post
    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
    Last edited by Edgemeal; Feb 9th, 2012 at 09:16 PM. Reason: check handle

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width