|
-
Nov 15th, 2006, 03:03 AM
#1
Thread Starter
Hyperactive Member
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?
-
Nov 15th, 2006, 03:07 AM
#2
Lively Member
Re: Minimize application when other application running..
Form1.WindowState = 1
or use these VB constants:
vbMinimized
vbMaximized
vbNormal
Does it work for you?
-
Nov 15th, 2006, 03:18 AM
#3
Thread Starter
Hyperactive Member
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?
-
Nov 15th, 2006, 03:24 AM
#4
Lively Member
Re: Minimize application when other application running..
VB Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
Private Type WINDOWPLACEMENT
length As Long
flags As Long
showCmd As Long
ptMinPosition As POINTAPI
ptMaxPosition As POINTAPI
rcNormalPosition As RECT
End Type
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hwnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_SHOWNORMAL = 1
' Find the target window and minimize, maximize,
' or restore it.
Private Sub cmdGo_Click()
Dim app_hwnd As Long
Dim wp As WINDOWPLACEMENT
' Find the target.
app_hwnd = FindWindow(vbNullString, txtTargetName.Text)
' Get the window's current placement information.
wp.length = Len(wp)
GetWindowPlacement app_hwnd, wp
' Set the appropriate action.
If optPlacement(0).Value Then
' Minimize.
wp.showCmd = SW_SHOWMINIMIZED
ElseIf optPlacement(1).Value Then
' Maximize.
wp.showCmd = SW_SHOWMAXIMIZED
Else
' Restore.
wp.showCmd = SW_SHOWNORMAL
End If
' Perform the action.
SetWindowPlacement app_hwnd, wp
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|