Win32/C++。我有一个多行编辑控件和一个按钮,我已将其设置为默认值 DM_SETDEFID
。当我按下回车键并将焦点放在编辑上时,我希望焦点保留在那里,而不是移动到按钮。
最佳答案
编辑控件应该有 ES_WANTRETURN
style将行为更改为所需的:
Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box's default push button. This style has no effect on a single-line edit control.
To change this style after the control has been created, use SetWindowLong.
关于winapi - 在对话框中,如何在编辑控件中按 Enter 键时阻止默认按钮获取焦点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9919467/