到网上搜了一些代码,,的确有些exe程序可以嵌入winform窗体里显示,但是有个问题,那个exe程序运行时弹出的窗体貌似是嵌入winform窗体了,但是以后在弹出的界面就不在winform窗体里了,高手们有什么思路提供吗?

解决方案 »

  1.   

    设置windows的样式为非顶层窗体,然后用api调用SetParent。你不启动你程序,直接启动那个程序,当然就是他本身,不在你的winform中了。
      

  2.   

    我是这样设置,,可是有些exe程序是可以,但是在继续点击exe程序里的窗体,就不在里面了,而且用qq测试,qq不会嵌入进去,这是什么问题呢?                 appWin = IntPtr.Zero; 
                    Process p = null;
                    try
                    {
                        p = System.Diagnostics.Process.Start(this.exeName);
                        p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;  
                        p.WaitForInputIdle();  
                        appWin = p.MainWindowHandle;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.Message, "Error");
                    }                // Put it into this form   
                    SetParent(appWin, this.Handle);                // Remove border and whatnot   
                    SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);                // Move the window to overlay it on this window   
                    MoveWindow(appWin, 0, 0, this.Width, this.Height, true);