Search code examples
mfcfocusactivation

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?


Solution

  • 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.