Proccess.start (mdi) Help Please
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
7 posts
Page 1 of 1
Hello i am trying to boot an external program inside an MDI as a child form so that i may add handlers to button presses
to suspend the use of them i am using this code
to suspend the use of them i am using this code
Code: Select all
and it boots it Fine but it is no a child its booting over the top of my program and acting tottaly independent any ideas on a fix please Try
proc = Process.Start(My.Settings.App_Path, String.Format("{0} {1} {2}", "", "12345", My.Settings.Server_Path))
proc.WaitForInputIdle()
SetParent(proc.MainWindowHandle, Me.Handle)
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
Catch ex As Exception
End Try
Removed old post, here's the new post:
I guess this is what you want to do:
Heres the full code:
I guess this is what you want to do:
Heres the full code:
Code: Select all
Public Class Form1
Declare Auto Function SetParent Lib "user32.dll" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Const WM_SYSCOMMAND As Integer = 274
Private Const SC_MAXIMIZE As Integer = 61488
Dim proc As Process
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim form As New Form
form.MdiParent = Me
form.Text = "Notepad inside the Form!"
form.BackColor = Color.Green
form.Show()
proc = Process.Start("C:\WINDOWS\notepad.exe")
proc.WaitForInputIdle()
SetParent(proc.MainWindowHandle, form.Handle)
SendMessage(proc.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
End Sub
End Class
You do not have the required permissions to view the files attached to this post.
Last edited by bisnes_niko on Fri Jan 04, 2013 8:01 pm, edited 1 time in total.
Add to Code:
and BTW,
if you add a MsgBox() to your Tyr Catch block.
you will underswtand more what type of error you atr getting.
Code: Select all
this allow the new "form" to be added to an existing form.form.TopLevel = false
and BTW,
if you add a MsgBox() to your Tyr Catch block.
you will underswtand more what type of error you atr getting.
Code: Select all
on a error or not, the MsgBox() will tell you what is going on.Try
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Thank you both but that code give me this error but loads both the program and a blank form system.invalidoperationexception: Process has exitedm, so the requested
information is not avaiable
information is not avaiable
muttley1968 wrote:Thank you both but that code give me this error but loads both the program and a blank form system.invalidoperationexception: Process has exitedm, so the requested#muttley1968 did you try the updated code I posted or the older one? This works fine on notepad.exe, but not working properly on some programs.
information is not avaiable
EDIT: Actually it works with everything I tested, just edit the WaitForIdle to:
Code: Select all
Threading.Thread.Sleep(5000)
Same thing is still hapening i am trying to make it start minecraft i dont know if that makes a diffrence but that is what i need to start
Sorry for double post but anyone got any ideas cant move on in my project until this part is working :(
7 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023