Win Form never gets focus?!?

Discussion in 'Microsoft Dot NET Framework Forms' started by Fre, Mar 12, 2008.

  1. Fre

    Fre Guest

    Hi all,

    In my winform application, I want to check on certain moments if my
    winform has focus. If so, some code will be executed. I noticed
    however, that the winform never gets the focus, even when it clearly
    has focus. How is that possible? What setting could I've messed with
    that causes my winform never to get focus, even when activated?

    void Form1_Activated(object sender, EventArgs e)
    {
    // always returns 'False' in my project (when I test
    // in new project, it returns 'True' however!!)
    Console.WriteLine("ACTIVATED & " + "this.Focused = " +
    this.Focused);
    }

    Thanks in advance for your answers.

    Frederik
     
    Fre, Mar 12, 2008
    #1
    1. Advertisements

  2. Try checking:

    if (Form.ActiveForm.Equals (this))
    ...

    instead of:

    if (this.Focused)
    ...

    /ravi

    ----------------------------
    "Fre" <> wrote in message
    news:...
    > Hi all,
    >
    > In my winform application, I want to check on certain moments if my
    > winform has focus. If so, some code will be executed. I noticed
    > however, that the winform never gets the focus, even when it clearly
    > has focus. How is that possible? What setting could I've messed with
    > that causes my winform never to get focus, even when activated?
    >
    > void Form1_Activated(object sender, EventArgs e)
    > {
    > // always returns 'False' in my project (when I test
    > // in new project, it returns 'True' however!!)
    > Console.WriteLine("ACTIVATED & " + "this.Focused = " +
    > this.Focused);
    > }
    >
    > Thanks in advance for your answers.
    >
    > Frederik
     
    Ravi Bhavnani, Mar 18, 2008
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hakan Gok

    A window that never gets focus

    Hakan Gok, Dec 22, 2003, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    156
    Hakan Gok
    Dec 22, 2003
  2. Guest

    TextBox OnPaint override never gets called

    Guest, Feb 3, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    3
    Views:
    6,689
    Ying-Shen Yu[MSFT]
    Feb 4, 2004
  3. Beren

    Topmost Form should never get focus

    Beren, Jul 17, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    7
    Views:
    460
    Beren
    Jul 19, 2004
  4. Phil Jones

    Consistently monitoring when a Form gets/loses focus.

    Phil Jones, Oct 25, 2004, in forum: Microsoft Dot NET Framework Forms
    Replies:
    3
    Views:
    262
    Jeffrey Tan[MSFT]
    Oct 26, 2004
  5. ConvertFrom never gets called even I defined CanConvertFrom

    , Jul 11, 2005, in forum: Microsoft Dot NET Framework Forms
    Replies:
    0
    Views:
    303
Loading...

Share This Page