How to accept Ctrl + Enter in CEdit

L

Landon

I use VC++ MFC 4.2.

I have a few MULTILINE CEdits.
If user press Enter key on one of the CEdit then it will act like Tab key
which is going to change focus to other CEdit.

If user press Ctrl + Enter, then it will act like Enter key in a notepad
which is going to a NEW line.

How to do that?

I have tried this code but if I press Ctrl + Enter, it acts like Tab. I was
confused.

Thank you.

BOOL CEditEx::preTranslateMessage(MSG* pMsg)
{
// TODO: ã“ã®ä½ç½®ã«å›ºæœ‰ã®å‡¦ç†ã‚’追加ã™ã‚‹ã‹ã€ã¾ãŸã¯åŸºæœ¬ã‚¯ãƒ©ã‚¹ã‚’呼ã³å‡ºã—ã¦ãã ã•ã„
if( pMsg->message == WM_KEYDOWN ){
if( pMsg->wParam == 11 && pMsg->wParam == 13 )
return CEdit::preTranslateMessage(pMsg);
else if( pMsg->wParam == 13 ) //13: ENTER KEY
pMsg->wParam = 9; // 9: TAB KEY
}

return CEdit::preTranslateMessage(pMsg);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top