CDialog DoModal(对话框打开,键盘焦点,但不是鼠标焦点)

时间:2012-09-07 15:52:35

标签: mfc focus mouse cdialog cricheditctrl

我有一个包含CRichEditCtrl控件的CDialog窗口(CDrafter)。

我重写了CDrafter :: PreTranslateMessage和CDrafter :: OnNotify,允许我用鼠标单击RichTextEdit中的特殊单词,然后再打开另一个对话框(MyDialog)。

*注意:我这样做是因为我不喜欢EN_LINK样式的限制。*

所以在CDrafter :: PreTranslateMessage中我有:

它只是确定点击的位置和单词(仅此而已)(等待OnNotify对其执行某些操作)。

所以在CDrafter :: 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在与父对话框相同的线程中调用。

我希望能够做到以下几点:

单击单词,打开MyDialog,单击MyDialog :: Cancel按钮,对话框关闭。

但是有一个问题,因为这是我的序列:

单击单词,MyDialog打开,单击MyDialog :: Cancel按钮(它不起作用 - 只更改鼠标图标),单击MyDialog :: Cancel按钮,对话框关闭

我需要(最初点击)鼠标,以便在新打开的对话框中获得任何鼠标控制。即按钮上的鼠标悬停事件等等,直到我(点击)。

0 个答案:

没有答案
相关问题