How to know if a form is not selected?
<p>I have a lots of problem to distinguish such a simple thing.</p>

<p>I need to know if a form is currently in front of everything, the one which receives key entries.</p>

<p>I have no way to know if it is.</p>

<p>I can check if not minimized. But then it may just be behind other windows, or just not being selected (for example it is openend, desktop is behind, you click on desktop, then you still see the application, but it doesn't receive key inputs).</p>

<p>The property <code>focus</code> is irrevelant for this.</p>

<p>Here is the code</p>

<pre><code>    protected override void OnActivated(EventArgs e)
    {
        base.OnActivated(e);

        if (this.Focused)
        {
            gotFocus = true;
            // never reaches tis
        }
</code></pre>