App in focus?

R

RobP

Is there a way to check with windows in c# whether the current application
is in focus and taking input? I've tried checking the focused property on
the main form, but this doesn't seem to work.

Thanks
RobP
 
F

Family Tree Mike

A form has focus, not an application. You could check if any form in the
application has focus. You would do such by looping over forms in your app
and checking the Focused proprerty. You would do something like this:

bool flag = false;
foreach (Form f in Application.OpenForms)
{
flag = flag | f.Focused;
}

I hope this helps.
 
R

RobP

Family Tree Mike said:
A form has focus, not an application. You could check if any form in the
application has focus. You would do such by looping over forms in your
app
and checking the Focused proprerty. You would do something like this:

bool flag = false;
foreach (Form f in Application.OpenForms)
{
flag = flag | f.Focused;
}

I hope this helps.

Thanks! I will give this a go.

Regards
RobP
 

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