What's the best way to minimize a non-vb application?
Printable View
What's the best way to minimize a non-vb application?
You have to use APIs to get the other apps window handle and then send to
message to minimize. Lookup FindWindow and SemdMessage APIs.
When working with APIs its best to download the API Guide and API Viewer from allapi.net.
How about doing this?
VB Code:
Option Explicit Private Declare Function ShowWindow Lib "user32" ( _ ByVal hwnd As Long, _ ByVal nCmdShow As Long _ ) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String _ ) As Long Private Const SW_HIDE = 0 Private Const SW_MINIMIZE = 6 Private Sub Command1_Click() Dim hWndApp As Long Dim strCaption As String Dim strProgram As String strProgram = "notepad.exe" strCaption = "Untitled - Notepad" 'see if program is already running hWndApp = FindWindow(vbNullString, strCaption) 'if not then start it If hWndApp = 0 Then Shell strProgram, vbNormalFocus While hWndApp = 0 hWndApp = FindWindow(vbNullString, strCaption) DoEvents Wend End If 'mimimize it MsgBox "Press OK to minimize" ShowWindow hWndApp, SW_MINIMIZE End Sub
...