<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 opens, without needing button etc.
In short, you want to put the main window (Form) of the process within its own Form? If so, the answer is is not possible. Unless you try to emulate the executable within a container implemented with virtualization, but that would take a lot of work. It’s very complicated.
– CypherPotato
it is possible I have seen a program using the same, when opening the program by clicking on the atalha, or directly in the exe the program recognizes the Process ID and sends to the form, thus emulating inside the form, without taking space in the explorer’s shortcut bar
– Wladi Veras
Yes, there is an application container, you would have to implement a.
– CypherPotato
yes, I would like to know how it is :P do not have the basis of how to make only this code above works I use this way, I will update
– Wladi Veras