我试图将按钮聚焦在自定义选项窗口中,该窗口以模态显示。我已经读过Prevent button from receiving focus in Inno Setup,并尝试使用ActiveControl
属性进行设置。这是代码:
[Code]
{ Create and show the Options window }
procedure ShowOptionsWindow;
var
OptionsOKButton, OptionsCancelButton: TButton;
begin
OptionsWindowForm := TForm.Create(WizardForm);
with OptionsWindowForm do
begin
Parent := WizardForm;
BorderStyle := bsDialog;
Position := poOwnerFormCenter;
ClientWidth := ScaleX(425);
ClientHeight := ScaleY(165);
Caption := '{#AppName} Options';
end;
{ Define the Options Cancel button }
OptionsCancelButton := TButton.Create(OptionsWindowForm);
with OptionsCancelButton do
begin
Parent := OptionsWindowForm;
Left := (OptionsWindowForm.ClientWidth - WizardForm.NextButton.Width) - (WizardForm.ClientWidth - (WizardForm.CancelButton.Left + WizardForm.CancelButton.Width));
Top := (OptionsWindowForm.ClientHeight - WizardForm.NextButton.Height) - ScaleY(12);
Width := WizardForm.NextButton.Width;
Height := WizardForm.NextButton.Height;
Caption := 'Cancel';
OnClick := @OptionsCancelButtonClick;
end;
{ Define the Options OK button }
OptionsOKButton := TButton.Create(OptionsWindowForm);
with OptionsOKButton do
begin
Parent := OptionsWindowForm;
Left := (OptionsCancelButton.Left - WizardForm.NextButton.Width) - ((WizardForm.CancelButton.Left - WizardForm.NextButton.Left) - WizardForm.NextButton.Width);
Top := OptionsCancelButton.Top;
Width := WizardForm.NextButton.Width;
Height := WizardForm.NextButton.Height;
Caption := 'OK';
OnClick := @OptionsOKButtonClick;
end;
OptionsWindowForm.ActiveControl := OptionsOKButton;
OptionsWindowForm.ShowModal;
end;
但是,运行此命令时,会出现以下错误:
我尝试通过在显示窗口之后放置它来更改调用时间,但是直到窗口关闭时它才被调用,因为ShowModal
仍然给出相同的错误时会停止脚本执行。有没有一种方法可以将按钮设置为在模式窗口中集中显示?