I have a small application that allows an external app to behave like a child form and open up in another form.
the code to do so is as follows
Dim myfile As String = (Application.StartupPath & "\MyHelp.exe")
MyClickedHelpProcess.StartInfo.FileName = (Application.StartupPath & "\MyHelp.exe")
MyClickedHelpProcess.Start()
Await Task.Run(Sub()
Dim timeout As DateTime = DateTime.Now.AddSeconds(10)
While timeout > DateTime.Now AndAlso MyClickedHelpProcess.MainWindowHandle.Equals(IntPtr.Zero)
Threading.Thread.Sleep(10)
End While
End Sub)
If (Not MyClickedHelpProcess.MainWindowHandle.Equals(IntPtr.Zero)) Then
SetParent(MyClickedHelpProcess.MainWindowHandle, Me.Handle)
end if
The code even works when I've added a Web browser control to the MyHelp.exe however if I add the following code to MyHelp.exe form load event the MyHelp.exe opens outside of the "parent like form". I cant figure out why or how to resolve this?
If My.Computer.FileSystem.FileExists("c:\MyHelp.html") Then
WebBrowser1.Navigate(New Uri("File:///c:/MyHelp.html"))
End If
If though I add a button to the MyHelp.exe form and place the following code in the button click event it dose work inside the makeshift "Parent form"...
WebBrowser1.Navigate(New Uri("File:///c:/MyHelp.html"))