How to put an exe from inside the form vb.net

-2

Well, I have the code

Dim proc As Process
proc = Process.Start("notepad.exe")
proc.WaitForInputIdle()
' Set the panel control as the application's parent
SetParent(proc.MainWindowHandle, Me.BetaBox.Handle)
'Maximize application
SendMessage(proc.MainWindowHandle, 274, 61488, 0)

It runs right, however I wanted it to put up the process inside the form even by opening it directly, is there any way? Do you need to do something similar?

    
asked by anonymous 11.04.2016 / 05:36

1 answer

0
   <DllImport("user32.dll")> Public Shared Function SetParent(ByVal hwndChild As IntPtr, ByVal hwndNewParent As IntPtr) As Integer
    End Function
    Const WM_NCLBUTTONDOWN As Integer = &HA1
    Const WM_LBUTTONDOWN As Integer = &H201
    Const HTCAPTION As Long = 2
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Integer) As Long
    Protected Overrides Sub WndProc(ByRef m As Message)
        MyBase.WndProc(m)
        If m.Msg = WM_LBUTTONDOWN Then
            ReleaseCapture()
            SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, &H0)
        End If
    End Sub

Private Sub Soul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Soul.Click

                Dim proc As Process
                proc = Process.Start("notepad.exe")
                proc.WaitForInputIdle()
                ' Set the panel control as the application's parent
                SetParent(proc.MainWindowHandle, Me.CommandLog.Handle)
                ' Maximize application
                SendMessage(proc.MainWindowHandle, 274, 61488, 0)
        End Sub

This code works by clicking the button, but I wanted it to recognize the application as soon as the application opened, without needing a button etc.

    
14.04.2016 / 02:11