Jyrka98
Jyrka98

Reputation: 530

How to make Inno Setup to show a MsgBox and close it automatically after specified time

How to make Inno Setup show a MsgBox after a application is started at the endm when all files are extracted, and make the MsgBox close itself in, lets say, 5 seconds.

And that MsgBox would say something like "Starting World of Tanks Client v0.8.10".

Upvotes: 2

Views: 5127

Answers (4)

Martin Prikryl
Martin Prikryl

Reputation: 202474

If you want a more customized implementation than the MessageBoxTimeout from @TLama's answer allows (like a countdown display or custom button captions):

For a complete code, see MsgBox - Make unclickable OK Button and change to countdown - Inno Setup.

Upvotes: 0

SystemAdmin
SystemAdmin

Reputation: 21

You could try to use vbscript's shell popup method. The popup should show for 5 seconds ...

[Files]
Source: "MyProg.exe"; DestDir: "{app}"

[Run]
Filename: "{app}\MyProg.exe"; AfterInstall: ShowVBScriptPopup; Flags: nowait

[Code]
procedure ShowVBScriptPopup;
var
  sh;
begin
  sh := CreateOleObject('WScript.Shell');
  sh.Popup('Huhu', 5, 'title');
end;

Upvotes: 0

TLama
TLama

Reputation: 76713

The following script shows how to start an application without waiting for its execution to be finished and immediately after the application is started show a message box for 5 seconds. For this you will need to use the nowait flag for the [Run] section entry, have an AfterInstall function, and a message dialog which is able to close itself after a time period (I have used the one from this post).

The principle is easy; when the [Run] section entry with your application is processed, the application is started and thanks to nowait flag, the entry is taken as processed immediately after the app starts. And since the AfterInstall trigger function is called when the entry is processed, we can show that message dialog from its assigned function:

[Files]
Source: "MyProg.exe"; DestDir: "{app}"

[Run]
Filename: "{app}\MyProg.exe"; AfterInstall: ShowStartingMessageBox; Flags: nowait

[Code]
#ifdef UNICODE
  #define AW "W"
#else
  #define AW "A"
#endif
const
  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 ShowStartingMessageBox;
begin
  MessageBoxTimeout(WizardForm.Handle, 'The application is starting... ' +
    'Ok, to be upright; it''s been started, but since its initialization ' +
    'takes a long time, we usually say it''s starting. This message will ' +
    'be automatically closed in 5 seconds!', 'Caption...',
    MB_OK or MB_ICONINFORMATION, 0, 5000);  
end;

Upvotes: 4

Slappy
Slappy

Reputation: 5472

That is not possible with Message Box (MsgBox() function) because it stops whole installation process and waits for user interaction.

You need to create

a) a new window which will be shown above installer window and

b) some kind of timer which will show/hide this window after appropriate time.

I think this can be easiier by writing simple C++/C#/Delphi plug-in than writing it in pure Pascal (Inno) code.

Upvotes: 0

Related Questions