你找找FindWindow和SetParent这两个windowsAPI的用法,就有个基本思路了。

解决方案 »

  1.   

     因为以前没做过这种 所以没什么思路。
    没有思路。基本思路是,在你的wpf里定义一个窗口,再窗口上加载个panel之类的东西,要有Windows句柄才行的。
    然后你使用process这个类打开外部程序(可以设置一些窗口的显示属性),获得外部程序的句柄后,利用SetParent,把外部程序句柄的父句柄设置为panel的句柄,这样外部exe程序就可以显示再panel上了,不过这个东西有些功能使用起来也很不如意的。不要在说你不知道句柄是什么之类的话。
      

  2.   


    SetParent(appWin, this.Handle);//this在这里是Panel控件4 // Remove border and whatnot
    5 SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);7 // Move the window to overlay it on this window
    8 MoveWindow(appWin, 0, 0, this.Width, this.Height, true);
    http://www.cnblogs.com/bitzhuwei/archive/2012/05/24/SmileWei_EmbeddedApp.html
      

  3.   


     项目是wpf的  wpf没有panel控件。
    在wpf里面如果用grid容器然后设置SetParent 加载的exe还是以主程序为父窗体。不是以grid。不清楚是怎么回事
      

  4.   

    SetParent要求控件的句柄(Handle),Grid没有这东西,只是布局用的
    WPF里面的StackPanel、DockPanel这么好用的你从来没用过吧?
    得到句柄
    new System.Windows.Interop.WindowInteropHelper(窗口).Handle
    (PresentationSource.FromDependencyObject(控件) as System.Windows.Interop.HwndSource).Handle
      

  5.   


     IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(dockPanel1)).Handle;
                Process  app = System.Diagnostics.Process.Start("NOTEPAD.EXE");
                IntPtr prsmwh = app.MainWindowHandle;
                //设置父窗口
                SetParent(prsmwh, hwnd);这样设置父窗体的话 出来的记事本是在整个窗体上 并不是在dock的。
      

  6.   

    我想要实现的效果很简单就是加载一个exe 这个exe的界面在我窗体的某个容器里面  看上去是我程序的界面就可以了