How to Un-Activate an app

G

Guest

Hi:

I would like to activate / un-acitvate my app's from time to time. I like
to do some action whenever the app is activated and in there the I will
un-activate it, waiting for external signal to activate it and do the same
action again and again. I put the action in the (main) Form.Activated event
handler, it does once. I have to click other application, in order to have my
app to lose focus, and click my app to get activated again to fire the
Activated handler

How do I un-acitivate the app, if possible, so it wil be ready to get
activated again and again automatically.
 
J

Justin Rogers

You have to set the focus to another application. I don't think there
are any out of the box APIs for setting the focus to another application,
so I'd recommend grabbing something off of pinvoke.net
 
G

Guest

Thanks, Justin:

OK, that confirms what I thought. It seems winForm just cannot get itself
out of focus and deactivated. I will go pinvoke.net to see if there is any
other thought.
 
G

Guest

You could just add a public method to the form that does your "activation"
call.

public void CustomProcess
{
if(!this.Focused)
this.Focus();
// TODO: put activation code here
}
 

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