[英]Embed Exe in Winform c# application: Mouse click not working on menustrip and toolstrip
我使用Menustrip和Toolstrip在VS 2010中创建了一个简单的Winform C#应用程序(.exe)。
现在,我使用以下代码将此应用程序嵌入到另一个Winform应用程序中。
问题是我无法在嵌入式应用程序中单击MenuItem或Toolstrip按钮。 Alt + F或键盘快捷键在起作用,但菜单或工具栏项上没有鼠标单击。 谢谢您的回复。
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);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.