Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

CRichEditCtrl Does Not Take the Return

0.00/5 (No votes)
6 Mar 2014 1  
CRichEditCtrl does not take the return

Introduction

Using the CRichEditCtrl control in combination with the Dialog creates a small problem like Dialog eats the return key pressed message. Although I was searching for a simple and quick solution for that, I have struggled to find a definite answer.

The quickest way to get around that problem is to override PreTranslateMessage() function of a Dialog and just return FALSE when the return key pressed message is called for the Rich Edit control...

Just copy/paste:

BOOL EditDlg::PreTranslateMessage(MSG* pMsg) 
{
    if(pMsg->message == WM_KEYDOWN)
    {
        if((pMsg->lParam == IDC_RICHDIALOG_EDIT_ID/*id of a Edit Box*/) && 
            (pMsg->wParam == VK_RETURN)
        {
            return FALSE;
        }
    }
    return CDialogEx::PreTranslateMessage(pMsg);
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here