-
March 28th, 2004, 11:38 PM
#1
Minimize, maximize, restore other window.
Is there a way to make my application tell something else to minimize/maximize/restore itself.
Example: My form commands Windows Media Player to minimize, but not just Media Player. I want to minimize/maximize/restore any window.
-
March 29th, 2004, 01:11 AM
#2
assuming you already knew the window handle, you can use SendMessage with WM_SYSCOMMAND message and SC_CLOSE, SC_RESTORE, SC_MAXIMIZE, SC_MINIMIZE constant
-
March 29th, 2004, 01:26 AM
#3
Newbie.
I am just a newbie, could you give me a rundown of each of those?
-
March 29th, 2004, 01:44 AM
#4
PHP Code:
Private Const SW_MAXIMIZE As Long = 3
Private Const SW_MINIMIZE As Long = 6
Private Const SW_RESTORE As Long = 9
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Sub cmdMax_Click()
Dim noteHwnd As Long
'Find notepad window, class name can be found using Spy++
noteHwnd = FindWindow("Notepad", vbNullString)
'or if you know the exact window title
noteHwnd = FindWindow(vbNullString, "Untitled - Notepad")
If noteHwnd <> 0 Then
'maximize the window
ShowWindow noteHwnd, SW_MAXIMIZE
End If
End Sub
-
March 29th, 2004, 04:30 PM
#5
Solved
Thank you Luthv for the help. I have come up with the solution without specifying a certain program.
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_MAXIMIZE As Long = 3
Private Const SW_MINIMIZE As Long = 6
Private Const SW_RESTORE As Long = 9
' Enter this in Sub-Routine
Ret = GetForegroundWindow()
ShowWindow Ret, SW_MAXIMIZE
This code will minimize whatever the active window is at the time.
-
June 3rd, 2013, 11:19 AM
#6
Re: Minimize, maximize, restore other window.
Many thanks for posting this, Luthv! It works perfectly for my purposes, which was to find a previously opened window and bring it to the front, whether it is minimized or sits behind other windows. I modified the code to add restore, then maximize, to account for all issues.
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_MAXIMIZE As Long = 3
Private Const SW_MINIMIZE As Long = 6
Private Const SW_RESTORE As Long = 9
Public Function FindAndMaximizeWindow(strWindowName) As Boolean
Dim noteHwnd As Long
'Find notepad window, class name can be found using Spy++
noteHwnd = FindWindow(strWindowName, vbNullString)
'or if you know the exact window title
noteHwnd = FindWindow(vbNullString, strWindowName)
If noteHwnd <> 0 Then
'maximize the window
ShowWindow noteHwnd, SW_RESTORE
ShowWindow noteHwnd, SW_MAXIMIZE
FindAndMaximizeWindow = True
Else
FindAndMaximizeWindow = False
End If
End Function
-
June 3rd, 2013, 10:36 PM
#7
Re: Minimize, maximize, restore other window.
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
|