当前位置:   article > 正文

海康visionmaster-VM 嵌入:嵌入用户软件界面的方法

海康visionmaster-VM 嵌入:嵌入用户软件界面的方法

描述
环境:VM4.0.0 + VS2015 及以上
现象:将 VM 整体嵌入到客户软件界面中?
解答
将 VM 软件整体嵌入到客户软件中,需要利用 Panel 控件,并且需要先启动 VM 软件,具
体代码如下:
C#
[DllImport(“User32.dll”, EntryPoint = “SetParent”)]
public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNew
Parent);
[DllImport(“user32.dll”, CharSet = CharSet.Auto)]
public static extern int MoveWindow(IntPtr hWnd, int x, int y, int n
Width, int nHeight, bool BRePaint);
// Start the process
p = System.Diagnostics.Process.Start
(@“D: \VisionMaster4.0.0\Applications\VisionMaster.exe”);
// Wait for process to be created and enter idle condition
p.WaitForInputIdle();
// Get the main handle
appWin = p.MainWindowHandle;
//需要等待 p 启动,可自行判断,可加上 Thread.Sleep(10000);
SetParent(appWin, panel1.Handle);//this 在这里是 Panel 控件
MoveWindow(appWin, 0, 0, this.panel1.Width, this.panel1.Height, tru
e);
最终效果如下图所示,VM 就整体嵌入到客户软件的 Panel 空间中,并且可以保持 VM 所
具备的功能
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/article/detail/40355
推荐阅读
相关标签
  

闽ICP备14008679号