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

Re: Win Form never gets focus?!? by Ravi

Ravi
Mon Mar 17 23:12:26 CDT 2008

Try checking:

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

instead of:

if (this.Focused)
...

/ravi

----------------------------
"Fre" <frederik12@gmail.com> wrote in message
news:21b098b5-da8c-46aa-8e8d-3c99f5a77a7f@k13g2000hse.googlegroups.com...
> 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