本文介绍了如何捕获click事件并指向form-> panel-> embedded exe,winform C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表格。
我在WinForm中运行这样的exe:
exe在一个面板中,面板在一个表单中。
此代码在面板中加载一个exe。没关系。
Hi,
I have a Form.
I'm running an exe inside WinForm like this:
exe is in a panel,panel is in a form.
This code is loading an exe in panel. It's ok.
private void Form1_Load(object sender, EventArgs e)
{
var path = @"C:\Users\Toshiba\WindowsApp.exe";
Process p = Process.Start(path);
Thread.Sleep(500); // Allow the process to open it's window
IntPtr ptr = IntPtr.Zero;
while ((ptr = p.MainWindowHandle) == IntPtr.Zero) ;
SetParent(p.MainWindowHandle, panel1.Handle);
MoveWindow(p.MainWindowHandle, 0, 0, this.Width - 90, this.Height, true);
p.EnableRaisingEvents = true;
}
当我点击exe上的任意一点时,我需要抓住它的观点(x,y)。我怎么能抓住这个事件呢?
谢谢。
我尝试了什么:
我尝试使用该代码捕获面板中的click事件(exe在面板中) )。但是这段代码没有提供所需的结果。
When I click on any point on the exe,i need to catch its point(x,y).How can i catch this event is it possible?
Thank you.
What I have tried:
I try that code to catch click event in panel(exe is in panel). But this code did not provide the desired results .
const int WM_PARENTNOTIFY = 0x0210;
const int WM_LBUTTONDOWN = 0x0201;
protected override void WndProc(ref Message m)
{
if (!this.DesignMode)
{
if (m.Msg == WM_PARENTNOTIFY)
{
if (m.WParam.ToInt32() == WM_LBUTTONDOWN)
{
}
}
}
base.WndProc(ref m);
}
推荐答案
这篇关于如何捕获click事件并指向form-> panel-> embedded exe,winform C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!