Inno Setup-创建自定义消息框(是/否) [英] Inno Setup - Create custom message box (yes / no)

查看:400
本文介绍了Inno Setup-创建自定义消息框(是/否)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建类似于以下代码的自定义消息框: Inno Setup-在消息框处隐藏X按钮(关闭)(对于一个消息框只有一个按钮),但是有两个按钮(是/否),每次选择可能有不同的操作.

How to create custom message box similar to this code: Inno Setup - Hide X button (close) at message box (for a message box with one button) but with two buttons, yes/no, with the possibility of different actions for each election.

推荐答案

只需添加第二个TButton:

function MyYesNoMessageBox: Integer;
var
  Form: TSetupForm;
  YesButton, NoButton: TNewButton;
  MesssageLabel: TLabel;
begin
  Form := CreateCustomForm;
  Form.BorderStyle := bsDialog;
  Form.Position := poOwnerFormCenter;
  Form.ClientWidth := ScaleX(400);
  Form.ClientHeight := ScaleY(130);
  Form.Caption := 'Caption';

  MesssageLabel := TLabel.Create(Form);
  MesssageLabel.Parent := Form;
  MesssageLabel.Left := ScaleX(16);
  MesssageLabel.Top := ScaleX(16);
  MesssageLabel.Width := Form.ClientWidth - 2*ScaleX(16);
  MesssageLabel.Height := ScaleY(32);
  MesssageLabel.AutoSize := False;
  MesssageLabel.WordWrap := True;
  MesssageLabel.Caption := 'Lorem ipsum dolor sit amet, ...';

  YesButton := TNewButton.Create(Form);
  YesButton.Parent := Form;
  YesButton.Width := ScaleX(80);
  YesButton.Height := ScaleY(24);
  YesButton.Left := Form.ClientWidth - 2 * (YesButton.Width + ScaleX(8));
  YesButton.Top := Form.ClientHeight - YesButton.Height - ScaleY(8);
  YesButton.Caption := '&Yes';
  YesButton.ModalResult := mrYes;

  NoButton := TNewButton.Create(Form);
  NoButton.Parent := Form;
  NoButton.Width := YesButton.Width;
  NoButton.Height := YesButton.Height;
  NoButton.Left := YesButton.Left + YesButton.Width + ScaleX(8);
  NoButton.Top := YesButton.Top;
  NoButton.Caption := '&No';
  NoButton.ModalResult := mrNo;

  Result := Form.ShowModal;
end;

并测试Form.ShowModal的返回码(或检查Form.ModalResult):

And test return code of Form.ShowModal (or check Form.ModalResult):

if MyYesNoMessageBox = mrYes then
begin
  MsgBox('Yes selected', mbInformation, MB_OK);
end
  else
begin
  MsgBox('No selected', mbInformation, MB_OK);
end;

这篇关于Inno Setup-创建自定义消息框(是/否)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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