Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Please let me know, the constructs I need to implement for enabling new line (Multiline Edit Control) when user selects <<ALT + ENTER>>.
in PreTranslateMessage()

...
...
C#
if((pMsg->message == WM_KEYDOWN) &&
     (pMsg->wParam == VK_RETURN))
  {
     //Enter key was hit -> do whatever you want
      <<some function to execute>>
    return TRUE;
  }


I presume the above code should handle <<ALT +ENTER>> instead of <<Enter>> , Hence, I have changed the (WM_KEYDOWN to WM_SYSKEYDOWN)but, in vain, it isn't working properly. Pls., let me know equivalent code handlers for <<ALT +ENTER>> keys.

Rgrds,
Posted
Updated 6-Mar-11 16:22pm
v2

1 solution

If you want a multiline textbox, you don't need to override PreTranslateMessage. All you have to do is dropping a classical Edit Control in your dialog and set its Multiline and Want Return properties to true.

If you still want to use PreTranslateMessage to know when the user presses ALT+ENTER, then use this code:
C++
BOOL CYourDialog::PreTranslateMessage(MSG* pMsg)
{
    if (pMsg->message == WM_SYSCHAR && pMsg->wParam == VK_RETURN)
    {
        //user pressed ALT+RETURN key
        ...
    }
    return CYourDialog::PreTranslateMessage(pMsg);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900