Mark Ingram
Mark Ingram

Reputation: 73673

How to create a non-interactive window in MFC

In my application I have a window which I popup with small messages on it (think similar to tooltip). This window uses the layered attributes to draw alpha backgrounds etc.

If I have several of these windows open at once, and I click one with my mouse, when they disappear they cause my application to lose focus (it switches focus to the app behind the current one).

How do I stop any interaction in my window?

Upvotes: 2

Views: 764

Answers (2)

Mark Ingram
Mark Ingram

Reputation: 73673

After playing with the WM_NCACTIVATE message with no luck, I overrode the WM_SETFOCUS message:

void CMyWindow::OnSetFocus(CWnd* pOldWnd)
{
    if (pOldWnd != NULL)
    {
        pOldWnd->SetFocus();
    }
}

That seems to do the trick. No idea why it works though! Comments welcome on that issue.

Upvotes: 1

Aidan Ryan
Aidan Ryan

Reputation: 11609

It works because OnSetFocus (like many of the On* methods) gives you a chance to pre-empt an action before it actually occurs. The focus never actually switches to your non-interactive window.

Upvotes: 1

Related Questions