Hosting a window from one process inside another
Every time this topic comes up, I seem to have lost my bookmarks on it. So, here's a blog entry so I won't lose them again...
Under Windows it is possible to visually "dock" the main window of one process inside a Window belonging to another process. You get the visual effect of one program, but there are still two completely separate exes involved.
I once used this to "host" an EXE inside Internet Explorer. We wrote a little tiny ActiveX (this was in the dark ages before managed code). All the ActiveX did was start our EXE, and then "dock" the EXE's main window inside the client area of the ActiveX. It looked like our EXE was the ActiveX - but our EXE had no idea that any of this was going on. It just doing its thing, running as an independent process.
The secret is the Windows API function SetParent. You can use it to set a window from process A as the parent of the main window of process B.
I haven't done this for a while. As I recall you need to make another call to make the hosted window look like a borderless child window (SetWindowLong IIRC) and I think I also had to detect resising of the "host" and programatically resize the child.
Here are some links on the subject, following a rather brief Google:
http://geekswithblogs.net/gyoung/archive/2006/04/26/76521.aspx
http://www.codeguru.com/forum/showthread.php?threadid=234862
http://www.codeproject.com/KB/miscctrl/winwordcontrol.aspx
I'm fairly sure I learnt this technique from something on Microsoft's site, in about 2000. But this post says they are no longer recommending it (at least, not for hosting Office apps) so perhaps that explains why I can't find the original MS post.
Under Windows it is possible to visually "dock" the main window of one process inside a Window belonging to another process. You get the visual effect of one program, but there are still two completely separate exes involved.
I once used this to "host" an EXE inside Internet Explorer. We wrote a little tiny ActiveX (this was in the dark ages before managed code). All the ActiveX did was start our EXE, and then "dock" the EXE's main window inside the client area of the ActiveX. It looked like our EXE was the ActiveX - but our EXE had no idea that any of this was going on. It just doing its thing, running as an independent process.
The secret is the Windows API function SetParent. You can use it to set a window from process A as the parent of the main window of process B.
I haven't done this for a while. As I recall you need to make another call to make the hosted window look like a borderless child window (SetWindowLong IIRC) and I think I also had to detect resising of the "host" and programatically resize the child.
Here are some links on the subject, following a rather brief Google:
http://geekswithblogs.net/gyoung/archive/2006/04/26/76521.aspx
http://www.codeguru.com/forum/showthread.php?threadid=234862
http://www.codeproject.com/KB/miscctrl/winwordcontrol.aspx
I'm fairly sure I learnt this technique from something on Microsoft's site, in about 2000. But this post says they are no longer recommending it (at least, not for hosting Office apps) so perhaps that explains why I can't find the original MS post.