I have a mfc sdi application without a doc/view architecture. The "view" is derived from CWnd. When the user right-clicks on the view a popup menu is created. Some commands of the popup menu might result in creating a modal dialog.

Unfortunately somehow the "view" rerains it's focus and unless I explicitly click on the modal dialog once it still gets commands.

There are two problems with that. The first is that to close the dialog, you must click it two times (which isn't horrible but it still is a pain in the donkey). The second is that mousemove messages sent to the view are still sent due to it having focus, and it's bad for the application behaviour.

I tried calling SetFocus in OnInitDialog of the dialogs and it didn't help. Even if it did though this isn't a solution since some of the dialogs are not mine and I don't have a control of their behaviour.

So can someone please help?