Mfc CDialog DoModal(对话框以键盘焦点打开,但不以鼠标焦点打开)
我有一个CDialog窗口(cdrfafter),其中包含一个CRichEditCtrl控件 我覆盖了CDRFAFTER::PreTranslateMessage和CDRFAFTER::OnNotify,以允许我用鼠标单击RichTextEdit中的特殊单词,从而打开另一个对话框(MyDialog) *注意:我这样做是因为我不喜欢EN_链接样式的局限性* 因此在cdrfafter::PreTranslateMessage中我有:Mfc CDialog DoModal(对话框以键盘焦点打开,但不以鼠标焦点打开),mfc,focus,mouse,cdialog,cricheditctrl,Mfc,Focus,Mouse,Cdialog,Cricheditctrl,我有一个CDialog窗口(cdrfafter),其中包含一个CRichEditCtrl控件 我覆盖了CDRFAFTER::PreTranslateMessage和CDRFAFTER::OnNotify,以允许我用鼠标单击RichTextEdit中的特殊单词,从而打开另一个对话框(MyDialog) *注意:我这样做是因为我不喜欢EN_链接样式的局限性* 因此在cdrfafter::PreTranslateMessage中我有: BOOL CSTANAGMessageDrafterDlg::On
BOOL CSTANAGMessageDrafterDlg::OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult )
{
BOOL r = CDialog::OnNotify(wParam, lParam, pResult);
//if (::PreTranslateMessage found a word clicked on ) {
MyDialog dialog;
dialog.DoModal();
//}
//Awesome my dialog opened and I can start editing the form (via the keyboard) no problems.
//BUG: There is a problem as the mouse curser is still showing the
// move carpet position icon as if it is still focused on the RichTextEdit control.
// If I click the mouse anywhere (in the MyDialog, or within the parent dialog)
// the mouse icon, and focus correctly changes to MyDialog, then I can click OK or CANCEL.
return r;
}
它只确定单击的位置和单词(仅此而已)(等待OnNotify对其进行处理)
因此在cdrfafter::OnNotify中,我有:
BOOL CSTANAGMessageDrafterDlg::OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult )
{
BOOL r = CDialog::OnNotify(wParam, lParam, pResult);
//if (::PreTranslateMessage found a word clicked on ) {
MyDialog dialog;
dialog.DoModal();
//}
//Awesome my dialog opened and I can start editing the form (via the keyboard) no problems.
//BUG: There is a problem as the mouse curser is still showing the
// move carpet position icon as if it is still focused on the RichTextEdit control.
// If I click the mouse anywhere (in the MyDialog, or within the parent dialog)
// the mouse icon, and focus correctly changes to MyDialog, then I can click OK or CANCEL.
return r;
}
我尝试过在MyDialog::DoModal之后调用“CDialog::OnNotify(wParam、lParam、pResult)”,但仍然看到相同的问题。
MyDialog::DoModal在与父对话框相同的线程中调用
我希望能够做到以下几点:
单击word,MyDialog打开,单击MyDialog::Cancel按钮,对话框关闭
但有一个问题,因为这是我的顺序:
单击word,MyDialog打开,单击MyDialog::Cancel按钮(它不工作-只有鼠标图标更改),单击MyDialog::Cancel按钮,对话框关闭
我需要(最初单击)鼠标,以便在新打开的对话框中获得任何鼠标控件。i、 e.按钮等上的鼠标悬停事件在我(单击)之前不起任何作用。没有鼠标焦点,只有键盘焦点。你只是在抱怨鼠标光标错了吗?光标图标错了,但功能也错了:在MyDialog中单击任何东西在第一次单击时都不起作用。第一次单击后,它可以正常工作。