Vuser_100706
2022-01-26 13:43
VM算法平台

VM怎样嵌入客户软件界面?

将VM整体嵌入到客户软件界面中?VM4.0.0 + VS2015及以上


  • 668
  • 0
  • 分享

全部回答1

(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所具备的功能

2022-01-26 14:00 未知地区
    |
  • 评论
  • |
  • 1

请升级浏览器版本

您正在使用的浏览器版本过低,请升级最新版本以获得更好的体验。

推荐使用以下浏览器