I have created a simple Winform C# application (.exe) in VS 2010 with Menustrip and Toolstrip.
Now I have embedded this application in another Winform application using the following code.
The problem is I can't click on MenuItem or Toolstrip buttons in the embedded application. Alt+F or keyboard shortcuts are working but no mouse clicks are working on menu or toolstrip items. Thank you for your reply.
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.Threading;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Process p = Process.Start("C:\\NewFolder\\myapplication.exe");
Thread.Sleep(500); // Allow the process to open it's window
SetParent(p.MainWindowHandle, panel1.Handle);
}
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
}
}
Try using
p.WaitForInputIdle();
Rather than
Thread.Sleep(500);
Found here: How can I run another application within a panel of my C# program? (includes lots more helpful stuff)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.