Win Form never gets focus?!?

  • Thread starter Thread starter Fre
  • Start date Start date
F

Fre

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
 
Try checking:

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

instead of:

if (this.Focused)
...

/ravi
 
Back
Top