问题描述
我有一个具有和按钮的modaldialog。对于,我将 Default
属性设置为True,对于按钮,取消
属性。 ModalResult设置为 mrOK
和 mrCancel
但是,不要按键盘上的或键关闭对话框。我在这里错过了什么?
编辑
我发布了一个报告此信息
I have a modaldialog with an and a button. For the I set the Default
property to True, and for the button the Cancel
property. ModalResult is set to mrOK
and mrCancel
, resp.
However neither pressing the nor the 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!