0

Here's the code...

ifdef UNICODE
  #define AW "W"
#else
  #define AW "A"
#endif
const
  MB_TIMEDOUT = 32000;
  MB_ICONERROR = $10;
  MB_ICONQUESTION = $20;
  MB_ICONWARNING = $30;
  MB_ICONINFORMATION = $40;

function MessageBoxTimeout(hWnd: HWND; lpText: string; lpCaption: string;
  uType: UINT; wLanguageId: Word; dwMilliseconds: DWORD): Integer;
  external 'MessageBoxTimeout{#AW}@user32.dll stdcall';

procedure InitializeWizard;
begin
  MessageBoxTimeout(WizardForm.Handle, 'Some ' +
    'message', 'Setup', MB_OK or MB_ICONINFORMATION, 0, 5000);
end;

I just want the message box to appear without the button. What code to be added or removed? Where would I insert it? Thanks!

Does this a code from How to disable the “Next” button on the wizard form in Inno Setup? work with my script? I can't seem to to make it working.

Community
  • 1
  • 1
DDoS
  • 361
  • 3
  • 13

1 Answers1

1

You cannot.

But as you already know from MsgBox - Make unclickable OK Button and change to countdown - Inno Setup, you can implement the message box from a scratch yourself. This way, you can customize it any way you want.

Actually, all you need is to remove the button from my answer to the above question.

[Code]

function SetTimer(hWnd: LongWord; nIDEvent, uElapse: LongWord; 
  lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: LongWord): BOOL;
  external 'KillTimer@user32.dll stdcall';

var
  TimeoutForm: TSetupForm;

procedure TimeoutProc(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
begin
  TimeoutForm.Tag := TimeoutForm.Tag - 1;
  if TimeoutForm.Tag = 0 then
  begin
    TimeoutForm.Close;
  end;
end;

procedure TimeoutMessageBoxCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  { Prevent the dialog from being closed by the X button and Alt-F4 }
  CanClose := (TimeoutForm.Tag = 0);
end;

procedure TimeoutMessageBox(Message: string; Seconds: Integer);
var
  MessageLabel: TLabel;
  Timer: LongWord;
begin
  TimeoutForm := CreateCustomForm;
  try
    TimeoutForm.ClientWidth := ScaleX(256);
    TimeoutForm.ClientHeight := ScaleY(64);
    TimeoutForm.Caption := 'Information';
    TimeoutForm.Position := poMainFormCenter;
    TimeoutForm.OnCloseQuery := @TimeoutMessageBoxCloseQuery;
    TimeoutForm.Tag := Seconds;

    MessageLabel := TLabel.Create(TimeoutForm);
    MessageLabel.Top := ScaleY(16);
    MessageLabel.Left := ScaleX(16);
    MessageLabel.AutoSize := True;
    MessageLabel.Caption := Message;
    MessageLabel.Parent := TimeoutForm;

    Timer := SetTimer(0, 0, 1000, CreateCallback(@TimeoutProc));

    try
      TimeoutForm.ShowModal();
    finally
      KillTimer(0, Timer);
    end;
  finally
    TimeoutForm.Free();
    TimeoutForm := nil;
  end;
end;  

For CreateCallback function, you need Inno Setup 6. If you are stuck with Inno Setup 5, you can use WrapCallback function from InnoTools InnoCallback library.

enter image description here

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992