Maximize a minimized application

I want to be able to maximize and bring focus to a minimized application already running.

How would I do that?
Who is Participating?
glass_cookieConnect With a Mentor Commented:
Here's something 'extra' to the previous comment:


Description: Maximize another application (3K)

That's it!

glass cookie :)
Here is a shortcut to a project that does what you want

Here is the site
Suat OzgurWeb / Application DeveloperCommented:
You should find its hwnd first. You can use the caption or a little part of the caption, or just a specific text in the caption to use it with FindWindow API function. Than you can do lots of thing with its hwnd. I am sorry because i have no vb in this computer so i dont want to drive you through the wrong way with codes i remembered. Actually visit and look for the FindWindow API (also some others to get hwnd and activating it). It is the good way to do what you need.

Good luck

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

this will find an application already running, you can state what the window api is if you wish and maximize it and return focus to it,

i believe this should do the trick

'Windows API/Global Declarations for :De
'     termin if Another Program is running Bas
'     ed on Portion of Window Caption
'API functions

Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long

Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean

Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long

Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Const MODULE As String = "modWindowsAPI"
    Private Const WPF_RESTORETOMAXIMIZED As Long = &H2
    Private Const SW_SHOWMAXIMIZED As Long = 3
    Private Const HWND_TOP As Long = 0
    Private Const SWP_SHOWWINDOW As Long = &H40

Private Type POINTAPI
    x As Long
    y As Long
    End Type

Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
    End Type

    Length As Long
    flags As Long
    showCmd As Long
    ptMinPosition As POINTAPI
    ptMaxPosition As POINTAPI
    rcNormalPosition As RECT
    End Type

' Name: Determin if Another Program is r
'     unning Based on Portion of Window Captio
'     n
' Description:This piece of code will lo
'     ok at each of the windows and return eac
'     h windows caption.
If you know the window / program you are looking for based on this caption this code will ring it to the front of the Z order and maximize it, even if the application is minimized.
If the application is not currently running you can then call the shell() command to launch the needed application at that time.
' By: Aaron Ralls
' Inputs:The only input would be the str
'     ing that you are looking for in the desi
'     red caption of the application you are i
'     n search for.
APPLCATION_CAPTION = "the text you are looking for"
I do an instr() to see if this string is inside of the forms caption.
' Returns:EnumAllWindows returns a TRUE
'     if the Application/window was never foun
'     d and a FALSE if it was found.
'Assumes:I'm currently working on a way
'     to convert a string you are looking for
'     to a long to be placed as the second par
'     amter of the EnumWindows and EnumWindows
'     Proc (the call back function).
'Side Effects:none that I know of. If an
'     y are found please contact me.
'This code is copyrighted and has limite
'     d warranties.
'Please see http://www.Planet-Source-Cod
'     vb/scripts/ShowCode.htm
'for details.

Private Const MODULE As String = "modWindowsAPI"
'NOTE this function must be in a bas mod
'     ule.
'the second parameter can be used for an
'     ything
'it is used in conjunction with the seco
'     nd parameter of EnumWindows
'ie you could change it to be byval List
'     View as ListView
'then the call back function could fill
'     that control.

Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal NotUsed As Long) As Boolean
    'Callback function for 'EnumWindows'
    On Error GoTo ErrorHandler
    Const SUBROUTINE As String = "EnumWindowsProc"
    'change the name of the caption you are
    '     looking for.
    Const APPLCATION_CAPTION As String = "SPP Reserve"
    Const FIRST_POSITION As Long = 1
    Const STRING_FOUND As Long = 0
    Dim Text As String 'The text of the new item
    Dim WindowPlacementPosition As WINDOWPLACEMENT
    Dim MinPoint As POINTAPI
    Dim MaxPoint As POINTAPI
    Dim Rectangle As RECT
    Dim ReturnValue As Long
    Text = WindowText(hwnd)

        MinPoint.x = 0
        MinPoint.y = 0
        MaxPoint.x = 0
        MaxPoint.y = 0
        Rectangle.Bottom = Screen.Height
        Rectangle.Left = 0
        Rectangle.Right = Screen.Width
        Rectangle.Top = 0
        WindowPlacementPosition.Length = Len(WindowPlacementPosition)
        WindowPlacementPosition.flags = WPF_RESTORETOMAXIMIZED
        WindowPlacementPosition.showCmd = SW_SHOWMAXIMIZED
        WindowPlacementPosition.ptMinPosition = MinPoint
        WindowPlacementPosition.ptMaxPosition = MaxPoint
        WindowPlacementPosition.rcNormalPosition = Rectangle
        ReturnValue = SetWindowPlacement(hwnd, WindowPlacementPosition)
        ReturnValue = ShowWindow(hwnd, SW_SHOWMAXIMIZED)
        ReturnValue = SetWindowPos(hwnd, HWND_TOP, 0, 0, Screen.Width, Screen.Height, SWP_SHOWWINDOW)
        ReturnValue = SetForegroundWindow(hwnd)

EnumWindowsProc = False
    'True to continue receiving data

EnumWindowsProc = True
End If
Exit Function
Debug.Assert False
Call MsgBox("Error in Procedure " & SUBROUTINE & " of " & MODULE & Err.Description)
End Function

Public Function EnumAllWindows() As Boolean

EnumAllWindows = False
    On Error GoTo ErrorHandler
    Const SUBROUTINE As String = "EnumAllWindows"

EnumAllWindows = EnumWindows(AddressOf EnumWindowsProc, 0)
    Exit Function
    Debug.Assert False
    Call MsgBox("Error in Procedure " & SUBROUTINE & " of " & MODULE & Err.Description)
End Function

Private Function WindowText(ByVal hwnd As Long) As String
    On Error GoTo ErrorHandler
    Const SUBROUTINE As String = "WindowText"
    Const DEFAULT_BUFFER_SIZE As Long = 255
    Dim ReturnValue As Long'The return value of GetWindowText.
    'It return the length of the text withou
    '     t the ending
    'null zero (chr(0))
    Dim Caption As String 'The class name of the Window that has the handle 'hwnd'
    Caption = Space(DEFAULT_BUFFER_SIZE) 'To retrive the name, you need to create a buffer.
    ReturnValue = GetWindowText(hwnd, Caption, Len(Caption))
    WindowText = Left(Caption, ReturnValue) 'Return the text of the window without the ending zero
    Exit Function
    Debug.Assert False
    Call MsgBox("Error in Procedure " & SUBROUTINE & " of " & MODULE & Err.Description)
End Function
'this is placed in a class or on a form
'this is a sample calling function.

Private Sub LoadContingencyProgram()
    On Error GoTo ErrorHandler
    Const SUBROUTINE As String = "LoadContingencyProgram"
    Const WINDOW_NOT_FOUND As Boolean = True

    If EnumAllWindows = WINDOW_NOT_FOUND Then
    End If
    Exit Sub
    Debug.Assert False
    Call MsgBox("Error in Procedure " & SUBROUTINE & " of " & MODULE & Err.Description)
End Sub

hope it helps

Here's a file over the net for you:


Description: Search for a particular minimized program and maximize it (3K)

That's it!

glass cookie : )
CArnoldAuthor Commented:
Sorry it took so long to get back, guys.  I wanted to examine everyone's suggestions and codes to determine the best possible solution to my problem.
Some code worked well with non-VB apps, but were very unpredictable and inconsistent with compiled VB .exe's.
Other links took me to well written code, but code that was heck to weed out the necessary code from the unnecessary.
glass_cookie's last link provided clean simple code of what I needed.

Thank you, to everyone, for your responses.  All were excellent.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.