App in focus?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RobP

    App in focus?

    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

  • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

    #2
    RE: App in focus?

    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.Ope nForms)
    {
    flag = flag | f.Focused;
    }

    I hope this helps.

    "RobP" wrote:
    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
    >
    >

    Comment

    • RobP

      #3
      Re: App in focus?

      "Family Tree Mike" <FamilyTreeMike @discussions.mi crosoft.comwrot e in
      message news:48E956E3-F83D-49A8-9300-86771A541194@mi crosoft.com...
      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.Ope nForms)
      {
      flag = flag | f.Focused;
      }
      >
      I hope this helps.
      >
      Thanks! I will give this a go.

      Regards
      RobP

      Comment

      Working...