Windows order problem when starting an external process

Windows order problem when starting an external process

am 17.10.2007 11:03:21 von ropo

I have a .NET 2.0 app that at one point starts an old MFC App through
System.Diagnostics.Process.Start from a model form/

I then wait for it to finish by calling StartedProcess.WaitForExit();

Problem is:

When I close the MFC app if there is an window behind my .NET app it
will come to the front leaving my .NET app at the back.

I've tried calling BringToFront before starting the MFC and after it
has finished but to no avail.

Note: if there is no other windows behind my application it is ok.


Anyone think of anything to try?

Re: Windows order problem when starting an external process

am 18.10.2007 18:11:01 von ropo

On Oct 17, 10:03 am, ropo wrote:
> I have a .NET 2.0 app that at one point starts an old MFC App through
> System.Diagnostics.Process.Start from a model form/
>
> I then wait for it to finish by calling StartedProcess.WaitForExit();
>
> Problem is:
>
> When I close the MFC app if there is an window behind my .NET app it
> will come to the front leaving my .NET app at the back.
>
> I've tried calling BringToFront before starting the MFC and after it
> has finished but to no avail.
>
> Note: if there is no other windows behind my application it is ok.
>
> Anyone think of anything to try?

I found the problem: My window that created the process set
"this.Enabled = false;" before starting the process, when a window is
disabled it in no longer available to windows (alt-Tab and its not
there). So after the process closes it returns to the next availble
window. My solution was to have the window disabled, the enable it
after starting the process and before WaitForExit().