I have this small chunk of code in an MDI form. When I press a menu item it does this:
The idea is to have a totally seperate program run inside an MDI for. If I just run this code it doesn't work. However, if I put a break point on the SetParent, and when it goes there F5 to continue it then works. It's almost like a timing thing. Like SetParent() can't set it right away. Does anyone have any advise? Putting any sort of sleep or wait really wouldn't be a great solution. This just seems very strange to me. Thanks in advance.
VB.NET:
Me.SuspendLayout()
Dim runProcess As New System.Diagnostics.Process
Dim info As New System.Diagnostics.ProcessStartInfo
info.FileName = "NotePad.exe"
info.WindowStyle = ProcessWindowStyle.Normal
runProcess = Process.Start(info)
SetParent(runProcess.MainWindowHandle, Me.Handle)
Me.ResumeLayout()
The idea is to have a totally seperate program run inside an MDI for. If I just run this code it doesn't work. However, if I put a break point on the SetParent, and when it goes there F5 to continue it then works. It's almost like a timing thing. Like SetParent() can't set it right away. Does anyone have any advise? Putting any sort of sleep or wait really wouldn't be a great solution. This just seems very strange to me. Thanks in advance.