Hallo Ich bin ein Anfänger Entwickler in Korea.C# öffnen Sie ein anderes Programm in Formular-Panel
Ich mache. Programm. Das Programm führt drei Exe (entwickelt in C++, C#) auf einem Formular aus und setzt das Programm in das Panel.
Jetzt lege ich das Programm in C++ oder andere Sprachen in das Panel. Windows-Programme, die mit C# erstellt wurden, bleiben jedoch nicht auf dem Panel. Hier ist ein Teil meines Code:
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll")]
static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint);
static readonly int GWL_STYLE = -16;
static readonly int WS_VISIBLE = 0x10000000;
private void Form1_Load(object sender, EventArgs e)
{
try
{
Process p = Process.Start("C:\\Users\\sonmi\\OneDrive\\Japan_Bunge_alpha\\Japan_Bunge_alpha\\bin\\Debug\\Japan_Bunge_alpha"); //C# program
Process p2 = Process.Start("C:\\Users\\sonmi\\Desktop\\astana_test\\astana\\Server\\Server_CES"); //C++ program
p.WaitForInputIdle();
Thread.Sleep(100);
SetParent(p.MainWindowHandle, this.Handle);
SetWindowLong(p.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
MoveWindow(p.MainWindowHandle, 0, 0, panel1.Width, panel1.Height, true);
p2.WaitForInputIdle();
SetParent(p2.MainWindowHandle, panel2.Handle);
SetWindowLong(p2.MainWindowHandle, GWL_STYLE, WS_VISIBLE);
MoveWindow(p2.MainWindowHandle, 0, 0, panel2.Width, panel2.Height, true);
}
ich jetzt zwei Platten verwendet habe, aber ich werde mehr hinzufügen, nachdem dieser Test vorbei ist. Ich weiß nicht, wo das Problem ist.
Was haben Sie in Ihrem 'catch' Block? Erhalten Sie einen Fehler? Hast du versucht, als Administrator zu laufen? – derloopkat