|
-
Dec 5th, 2000, 12:49 AM
#1
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
-
Dec 5th, 2000, 01:24 AM
#2
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
-
Dec 5th, 2000, 02:20 AM
#3
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
-
Dec 5th, 2000, 08:39 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|