Modaldialog没有反应进入/ esc [英] Modaldialog doesn't react to enter/esc

查看:234
本文介绍了Modaldialog没有反应进入/ esc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有 OK 取消按钮的modaldialog。对于 OK ,我将 Default 属性设置为True,对于取消按钮,取消属性。 ModalResult设置为 mrOK mrCancel



但是,不要按键盘上的 Enter Esc 键关闭对话框。我在这里错过了什么?



编辑

我发布了一个报告此信息


I have a modaldialog with an OK and a Cancel button. For the OK I set the Default property to True, and for the Cancel button the Cancel property. ModalResult is set to mrOK and mrCancel, resp.

However neither pressing the Enter nor the Esc key on my keyboard close the dialog. What did I miss here?

edit
I posted a small test application using the suspect dialog on my site. IDE is RAD Studio XE3.

解决方案

For the record, this should work. However, it seems that TSpinEdit has a bug. Since TSpinEdit is a sample (Vcl.Samples.Spin.pas, note the "Samples"), you can fix this yourself.

To TSpinEdit, add the following method declaration just following WMCut:

   procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;

Complete the class (Shift+Ctrl+C) and add the following code to WMGetDlgCode:

procedure TSpinEdit.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
  inherited;
  Message.Result := Message.Result and not DLGC_WANTALLKEYS;
end;

That will tell VCL that the edit control doesn't want to process the Enter and Escape keys (VK_ENTER, VK_ESCAPE). Since it doesn't process the keys, they'll be forwarded to the buttons, which will then be invoked base on their settings (Default & Cancel).

Feel free to report this at Quality Central

这篇关于Modaldialog没有反应进入/ esc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆