Better way to “dock” a third party running application inside a windows.forms panel?

StackOverflow https://stackoverflow.com/questions/1435358

  •  07-07-2019
  •  | 
  •  

Question

I am currently doing this as follows:


// _Container is the panel that the program is to be displayed in.

System.Diagnostics.Process procTest = new System.Diagnostics.Process();
procTest.StartInfo.FileName = "TEST.EXE";
procTest.StartInfo.CreateNoWindow = false;
procTest.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
procTest.Start();

procTest.WaitForInputIdle();
SetParent(procTest.MainWindowHandle, _Container.Handle);
MoveWindow(procTest.MainWindowHandle, 
           0, 0, _Container.Width, _Container.Height, true);

The problem I am having with this code is that some parts of the application UI no longer function properly once I change the MainWindowHandle (ie: buttons missing text).

Is there a way to do this without causing issues with the docked application? (Either through .net or user32)?

Was it helpful?

Solution

First of all, instead of simply waiting 1.5 seconds, try calling procTest.WaitForInputIdle to wait until its message loop is free. You already are.

In general, I don't think it's possible to do this without modifying the program that you're hosting.

EDIT: You could try to keep the other program above your hosting area by hiding in from the taskbar, removing its title bar, moving it as your program moves, etc. However, this still wouldn't work perfectly; I recommend that you try to find some alternative.

Try contacting the original developers of the third-party application and asking for their advice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top