Witam
Posiadam pewien problem z kodem , a mianowicie chciałbym by zewnętrzna aplikacja exe wyświetlała się w panelu. Jak można to rozwiązać ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.IO;
namespace zewnetrzny_exe_proba_3
{
public partial class Form1 : Form
{
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
public Process proc;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (proc == null || proc.HasExited)
{
proc = Process.Start(@"C:\Program Files\TenDollars2Surf\TenDollars2Surf.exe"); // or whatever
//proc = Process.Start("C:\Program Files\TenDollars2Surf\TenDollars2Surf.exe");
proc.WaitForInputIdle();
SetParent(proc.MainWindowHandle, panel1.Handle);
MoveWindow(proc.MainWindowHandle, 0, 0, panel1.Width, panel1.Height, false);
}
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (!proc.HasExited) proc.Kill();
}
}
}