(winform) 将VM软件整体嵌入到客户软件中,需要利用Panel控件,并且需要先启动VM软件,具体代码如下:
1. C#
2. [DllImport("User32.dll", EntryPoint = "SetParent")]
3. public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
4.
5. [DllImport("user32.dll", CharSet = CharSet.Auto)]
6. public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool BRePaint);
7.
8. // Start the process
9. p = System.Diagnostics.Process.Start (@"D: \VisionMaster4.0.0\Applications\VisionMaster.exe");
10. // Wait for process to be created and enter idle condition
11. p.WaitForInputIdle();
12. // Get the main handle
13. appWin = p.MainWindowHandle;
14. //需要等待p启动,可自行判断,可加上Thread.Sleep(10000);
15. SetParent(appWin, panel1.Handle);//this在这里是Panel控件
16. MoveWindow(appWin, 0, 0, this.panel1.Width, this.panel1.Height, true);
最终效果如下图所示,VM就整体嵌入到客户软件的Panel空间中,并且可以保持VM所具备的功能
基于C++OpenCV实现VisionMaster中的“直线边缘缺陷检测”
2024-03-04 09:41:20