Results 1 to 4 of 4

Thread: Minimize application when other application running..

  1. #1

    Thread Starter
    Hyperactive Member Bearnerd's Avatar
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    290

    Minimize application when other application running..

    I use shellexecute to run another program but I want my vb application minimized when I click the cmdbutton. How can I do that?

  2. #2
    Lively Member djklocek's Avatar
    Join Date
    Aug 2006
    Posts
    107

    Re: Minimize application when other application running..

    Form1.WindowState = 1

    or use these VB constants:

    vbMinimized
    vbMaximized
    vbNormal

    Does it work for you?

  3. #3

    Thread Starter
    Hyperactive Member Bearnerd's Avatar
    Join Date
    Apr 2006
    Location
    Malaysia
    Posts
    290

    Re: Minimize application when other application running..

    Yes its working for me. But I want to minimize not only my application but any other applications that running on taskbar. If possible I want to fire the 'show desktop' quick launch. Is there any API call can do this?

  4. #4
    Lively Member djklocek's Avatar
    Join Date
    Aug 2006
    Posts
    107

    Re: Minimize application when other application running..

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    4.  
    5. Private Type POINTAPI
    6.     X As Long
    7.     Y As Long
    8. End Type
    9. Private Type RECT
    10.     Left As Long
    11.     Top As Long
    12.     Right As Long
    13.     Bottom As Long
    14. End Type
    15. Private Type WINDOWPLACEMENT
    16.     length As Long
    17.     flags As Long
    18.     showCmd As Long
    19.     ptMinPosition As POINTAPI
    20.     ptMaxPosition As POINTAPI
    21.     rcNormalPosition As RECT
    22. End Type
    23. Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
    24. Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
    25. Private Const SW_SHOWMINIMIZED = 2
    26. Private Const SW_SHOWMAXIMIZED = 3
    27. Private Const SW_SHOWNORMAL = 1
    28. ' Find the target window and minimize, maximize,
    29. ' or restore it.
    30. Private Sub cmdGo_Click()
    31. Dim app_hwnd As Long
    32. Dim wp As WINDOWPLACEMENT
    33.  
    34.     ' Find the target.
    35.     app_hwnd = FindWindow(vbNullString, txtTargetName.Text)
    36.  
    37.     ' Get the window's current placement information.
    38.     wp.length = Len(wp)
    39.     GetWindowPlacement app_hwnd, wp
    40.  
    41.     ' Set the appropriate action.
    42.     If optPlacement(0).Value Then
    43.         ' Minimize.
    44.         wp.showCmd = SW_SHOWMINIMIZED
    45.     ElseIf optPlacement(1).Value Then
    46.         ' Maximize.
    47.         wp.showCmd = SW_SHOWMAXIMIZED
    48.     Else
    49.         ' Restore.
    50.         wp.showCmd = SW_SHOWNORMAL
    51.     End If
    52.  
    53.     ' Perform the action.
    54.     SetWindowPlacement app_hwnd, wp
    55. End Sub




    There is something like above. Is it ok?
    You can see for yourself here.
    Last edited by djklocek; Nov 15th, 2006 at 03:33 AM.

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