Results 1 to 2 of 2

Thread: Activating A Minimized Application on Taskbar

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2001
    Location
    Lancashire England
    Posts
    36

    Question Activating A Minimized Application on Taskbar

    Does anyone know how to activate a window that is currently minimized on the taskbar?
    I have tried the following code but the focus remains with my Visual Basic Application instead of the rquired window.

    Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) As Long
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal aint As Integer) As Integer
    Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Integer) As Long
    Public Const GW_HWNDNEXT = 2
    Public Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
    Private Declare Function Putfocus Lib "user32" Alias "SetFocus" (ByVal hWnd As Long) As Long
    Declare Function SetActiveWindow Lib "user32.dll" (ByVal hWnd As Long) As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

    Public Sub ActivateWindowByTitle(ByVal WndCap As String)
    Dim hWndFrame As Long
    hWndFrame = FindWindowPartial(WndCap)
    If hWndFrame <> 0 Then
    ' Activate the window
    'Call BringWindowToTop(hWndFrame)
    Call SetForegroundWindow(hWndFrame)
    'Call SetActiveWindow(hWndFrame)
    'Call ShowWindow(hWndFrame, 1)
    Call ShowWindow(hWndFrame, 10)
    End If
    End Sub

    Public Function FindWindowPartial(ByVal TitlePart As String) As Long
    Dim hWndTmp As Long
    Dim nRet As Integer
    Dim TitleTmp As String
    TitlePart = UCase$(TitlePart)
    hWndTmp = FindWindow(0&, 0&)

    Do Until hWndTmp = 0
    TitleTmp = Space$(256)
    nRet = GetWindowText(hWndTmp, TitleTmp, Len(TitleTmp))
    If nRet Then
    TitleTmp = UCase$(VBA.Left$(TitleTmp, nRet))
    If InStr(TitleTmp, TitlePart) Then
    FindWindowPartial = hWndTmp
    Exit Do
    End If
    End If
    hWndTmp = GetWindow(hWndTmp, GW_HWNDNEXT)
    Loop
    End Function

    Private Sub CmdTest_Click()
    Call ActivateWindowByTitle("Notepad")
    End If
    Chris

  2. #2
    Fanatic Member pradeepkrao's Avatar
    Join Date
    Sep 2001
    Location
    New Jersey
    Posts
    534
    Use PostMessage(hWnd,WM_ACTIVATEAPP,0,0)..

    Regards,
    Pradeep
    Learn by others experience as you cannot live long to experience them all.
    www.freewebs.com/pradeepkrao

    LOOK AT MY GAMES AT MY WEB SITE.

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