winapi - 在对话框中,如何在编辑控件中按 Enter 键时阻止默认按钮获取焦点?

标签 winapi user-interface button focus editcontrol

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/

相关文章:

vb.net - 调用类与结构时抛出错误

c++ - 在窗口标题和消息框中显示错误的语言 : win32 application, opengl

c++ - windows EnumProcesses 某些进程名称为 <unknown>

css - 如何在 table 隐藏部分的边缘正确转换阴影?

javascript - 如何使用 jQuery 更改 Bootstrap 按钮属性

javascript - 单击时,将短代码/bbcode 添加到文本区域?

c++ - 从 C++ 中的另一个 .exe 生成用户自定义的 .exe

c++ - QLineEdit 可见宽度设置?

python - 我的 UI 布局中的奇怪间距

java - 字符串无法转换为 java 错误