Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The standard behavior of a CDialog is that it designates the <code>Enter</code> key as clicking the OK-button and the <code>ESC</code> key as the cancel-button, these messages are handled in the default handler inside MFC framework. If you want a different behavior than this, you have to override the IDOK and IDCANCEL click-message handlers.</p> <p>However your problem about the edit-box response to the <code>Enter</code> key is a totally different problem itself. It is because edit-box in default, is only for handling single line text entry and does not respond to a <code>Enter</code> key code. </p> <p>To enable the edit-box for multi-line entry, you have to set the <code>Multi-line</code> and <code>Want return</code> property of the edit-box in the dialog editor.</p> <p>Additional infomations after the first comment from the OP -----------------</p> <p>The <code>OK</code> button is high-lighted because it is set as the default respond button of the dialog. Remove the <code>Default Button</code> in the property of this button in the dialog editor. This is, however for the visual display only, you may have to remove this <code>OK</code> button for what you want to work.</p> <p>To disable <code>Enter</code> key as the dialog exit, you have to add a bypass handler as follows:</p> <pre><code>// add a message routing macro entry in the message map ON_BN_CLICKED(IDOK, OnFilterDefaultExitKey) // add a function prototype in the {{AFX_MSG() declaration afx_msg void OnFilterDefaultExitKey(); // add a handler in the class implementation file /* ==================================== */ void CTest1Dlg::OnFilterDefaultExitKey() { // default exit key handler, ignore everything. } </code></pre> <p>However, adding code in this way will also render the <code>OK</code> key completely useless, not responding to any click at all. So you have to add a <code>Done</code> button manually to handle the finalization of the edited data by the user. </p> <pre><code> /* ========================== */ void CTest1Dlg::OnButtonDone() { EndDialog(IDOK); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload