Inno Setup - Hide X button (close) at message box

前端 未结 1 2004
时光取名叫无心
时光取名叫无心 2021-02-11 11:11

How to hide X button at message box?

I want to see this, if is possible:

1条回答
  •  青春惊慌失措
    2021-02-11 11:19

    I do not think this is possible.

    One possible workaround is to implement the message box from the scratch.

    And remove the biSystemMenu from the TForm.BorderIcons (or actually setting it empty).

    procedure MyMessageBoxWithoutCloseButton;
    var
      Form: TSetupForm;
      Button: TNewButton;
      MesssageLabel: TLabel;
    begin
      Form := CreateCustomForm;
      Form.BorderStyle := bsDialog;
      Form.Position := poOwnerFormCenter;
      Form.ClientWidth := ScaleX(400);
      Form.ClientHeight := ScaleY(130);
      Form.BorderIcons := []; { No close button }
      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, ...';
    
      Button := TNewButton.Create(Form);
      Button.Parent := Form;
      Button.Width := ScaleX(80);
      Button.Height := ScaleY(24);
      Button.Left := Form.ClientWidth - Button.Width - ScaleX(8);
      Button.Top := Form.ClientHeight - Button.Height - ScaleY(8);
      Button.Caption := 'Accept';
      Button.ModalResult := mrOK;
    
      Form.ShowModal;
    end;
    


    Note that it's still possible to close the message box using Alt-F4.

    To prevent that handle OnCloseQuery. For an example, see How to Delete / Hide / Disable [OK] button on message box.

    0 讨论(0)
提交回复
热议问题