System.Diagnostics.Process.Start forcing browser to stay on top

M

mBird

I launch a file in the browser from a function in my application:
string f = "test.htm";
System.Diagnostics.Process.Start(f);
The browser stays on top (so the application gets hidden under the browser).

But ...
When I put System.Diagnostics.Process.Start() in a class and make a method
for it then instantiate that class in my applciation and do
myclass.mymethod(filename) the browser pops up but then the app makes itself
frontmost (so it covers the browser).

So one way the browser ends up behind the app window ack and the other way
topmost.

Can I control which it does (I want the browser to always be frontmost, on
top)?

Thank you
 
Y

Ying-Shen Yu[MSFT]

Hi mBird,
I couldn't repro this difference as you described on my system, however, I
think you want to make the browser window on top of your app. Here is a
work around maybe helpful to you, you may try using the Win32 API
SetWindowPos by PInvoke to make the main window of the new process top(or
always on top).

First you should get the Process you want, from your code snippet It seems
that you just provided the url and didn't provide a executable filename to
the start method, it's ok but the new process was spawned by the shell,so
you couldn't get information on the new process in the returned object.If
you want to use this way, you need call GetProcessByName to find the newly
created process first.

After you get the corresonding process object, you can get the
MainWindowHandle of that process, then you can use the SetWindowPos. Maybe
you will need another API GetWindowRect to retrieve the location and size
of the current window.

Does this helpful to your problem?
If you have anything unclear, please be free to reply to this group.
Thanks!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
Y

Ying-Shen Yu[MSFT]

Hi mBird,
How about your problem now?
If you still have problem on this issue, please be free to reply me in this
group.
Thanks!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
M

mBird

Hi --
I have not had time to try it yet -- but will hopefully soon. Thanks for
your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top