Вот у меня примерчик один завалялся, может это то что надо Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function IsIconic Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Const SW_RESTORE = 9 Const WM_SETTEXT = &HC Const BM_CLICK = &HF5 ' Top MS secret? Not included into API32.txt 'Code Private Sub ProcessCommandLine(sCommand As String) 'Your code here ' MsgBox "Excuted with command: " & sCommand If Text1.Text <> "" Then Text1.Text = Text1.Text & vbCrLf Text1 = Text1 & "Excuted with command: " & sCommand End Sub Private Sub cmdDummy_Click() ProcessCommandLine cmdDummy.Caption cmdDummy.Caption = "Ready for command" End Sub Private Sub Form_Load()  im h As Long, hButton As Long  im sCaption As String, sCommand As String cmdDummy.Visible = False sCaption = "Your Caption" Text1 = "" sCommand = Command If App.PrevInstance Then h = FindWindow(vbNullString, ByVal sCaption) ActivateWindow h hButton = FindWindowEx(h, 0, vbNullString, ByVal "Ready for command") SendMessage hButton, WM_SETTEXT, 0, ByVal sCommand SendMessage hButton, BM_CLICK, 0, ByVal 0& Unload Me Exit Sub Else Caption = sCaption cmdDummy.Caption = sCommand cmdDummy_Click End If End Sub Private Sub ActivateWindow(h As Long) If h Then If IsIconic(h) Then Call ShowWindow(h, SW_RESTORE) End If Call SetForegroundWindow(h) Else Exit Sub 'no need to continue. End If End Sub
Ответить
|