Results 1 to 4 of 4

Thread: Is that External Window Maximized ??

  1. #1
    Guest
    How can I tell if an external window is maximized? Also, if it is maximized, I want to restore it so that its not maximized (the equivilant of clicking the middle button on the window).

    Any ideas?
    Jordan

  2. #2
    Guest
    Use the IsZoomed api function to tell if a window is maximized or not.

    Code:
    Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
    lpWindowName As String) As Long
    
    Private Declare Function IsZoomed Lib "user32" (ByVal _
    hwnd As Long) As Long
    
    Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As _
    Long, ByVal nCmdShow As Long) As Long 
    
    Private Const SW_RESTORE = 9
    
    Private Sub Command1_Click()
    
         hWin = FindWindow("notepad", vbNullString)
         If hWin <> 0 Then
              If IsZoomed(hWin) Then
                   ShowWindow hWin, SW_RESTORE
              End If
         End If
    
    End Sub

  3. #3
    Guest
    Thanks Matthew, works great. Just wondering, whats the difference between SW_NORMAL and SW_RESTORE? I'm using SW_NORMAL and it seems to work fine.

    Thanks,
    Jordan

  4. #4
    Guest
    SW_NORMAL = 1
    SW_RESTORE = 9

    Normal shows window as normal, which will just bring up and give focus to the window.
    Restore restores the window when it has been maximized (and maybe minimized ?)

    Glad it worked for you.

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