Modal dialog doesnt get focus
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?
Re: Modal dialog doesnt get focus
How do you create/pop up this modal dialog? What peculiar do you do in its OnInitDialog handler?
Post some code.
Re: Modal dialog doesnt get focus
Quote:
Originally Posted by VictorN
How do you create/pop up this modal dialog? What peculiar do you do in its OnInitDialog handler?
Post some code.
It's truly simple :) It hapens to every dialog. Even to an example dialog that doesn't even have it's own class. Here is how i create it:
Code:
void CTheView::OnSomeCommand()
{
CDialog dlg(IDD_SAMPLE /*, this*/);
dlg.DoModal();
}
The parent parameter of the constructor doesn't change a thing. No mater if it's the view or the main frame.
Oh and another thing. The dialog does get focus if the command is sent from the application menu (IDR_MAINFRAME) but if the same command is sent through the popup menu that appears on right-clicking the view the dialog doesn't get focus.
Re: Modal dialog doesnt get focus
Still not clear...
If you are using VC6.0 then try to create a small test project representating your problem and post it to the forum (.zip without Releasa, Debug subfolders and without .ncb file)