Preventing an app from stealing focus?

S

Sam Marrocco

I'm using a vb.net app to start a process (which is a small shell
application). When the shell app runs, even in minimized form, it
"steals" the focus from the current app on the desktop. This is
undesirable. Is it possibly to prevent a new process from taking the
focus of the mouse from the current app when it runs?
--
==================================================================
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
==================================================================
 
C

Cor

Sam,

Maybe there is a possibility, however my first thought was how you will draw
it on the screen when it has no focus?

When it is in your own application, than is what you can do in my opinion,
is setting the other form to Topmost.

I hope this helps,

cor
 
T

Tom Shelton

I'm using a vb.net app to start a process (which is a small shell
application). When the shell app runs, even in minimized form, it
"steals" the focus from the current app on the desktop. This is
undesirable. Is it possibly to prevent a new process from taking the
focus of the mouse from the current app when it runs?

How are you starting the process? Using shell or
System.Diagnostics.Process?

If using Shell, have you tried passing AppWinStyle.NormalNoFocus or
AppWinStyle.MinimizedNoFocus?

I have a possilbe API solution in mind if all else fails, but it would
be better to keep it in the managed world if possible :)
 
S

Sam Marrocco

Tom said:
How are you starting the process? Using shell or
System.Diagnostics.Process?


I'm using System.Diagnostics.Process. Here's a little background:

My vb.net application runs on a machine, waiting for a command (from a
server) to run a shell/dos application (which I did *not* write). The
shell app quits, and then my app awaits another command.

I originally wrote the vb.net app to launch the shell app as a
ProcessWindowStyle.Hidden type, but when doing this I realized that I
could never kill the dos application if the need arose, because the
shell app was then "hidden" from view. There are occasions that my app
might need to kill the shell task, so I've stayed with processes for
this reason--so my app can track the status (running/stopped) of the
shell task). I then switched to a ProcessWindowStyle.Minimized. This
allows the shell app to be killed, but now steals the focus from other
running apps. Hence my dilemma.

As you suggested, I've been trying to keep everything in managed code if
possible.

If using Shell, have you tried passing AppWinStyle.NormalNoFocus or
AppWinStyle.MinimizedNoFocus?

I have a possilbe API solution in mind if all else fails, but it would
be better to keep it in the managed world if possible :)

--
==================================================================
Sam J. Marrocco
Sr. Visual Effects Artist/R&D
Travelling Pictures/GTN
Inferno, Flame, Maya, All that cool stuff!
"The fact that no one understands you doesn't make you an artist."
==================================================================
 

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