[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[Code]
procedure UninsNextButtonOnClick(Sender: TObject);
begin
with UninstallProgressForm.InnerNotebook do
begin
ActivePage := Pages[ActivePage.PageIndex + 1]; // go to next page
if ActivePage.PageIndex = PageCount-1 then // on last page...
begin
TButton(Sender).Hide; // ...hide Next button...
UninstallProgressForm.Close; // ...and close modal form
end;
end;
end;
procedure UninsCancelButtonOnClick(Sender: TObject);
begin
UninstallProgressForm.ModalResult := mrAbort;
end;
procedure InitializeUninstallProgressForm();
var
Page: TNewNotebookPage;
UninsNextButton: TButton;
begin
with UninstallProgressForm do
begin
// create Next button
UninsNextButton := TButton.Create(UninstallProgressForm);
with UninsNextButton do
begin
Parent := UninstallProgressForm;
Top := UninstallProgressForm.CancelButton.Top;
Width := UninstallProgressForm.CancelButton.Width;
Height := UninstallProgressForm.CancelButton.Height;
Left := UninstallProgressForm.CancelButton.Left - Width - ScaleX(10);
Caption := SetupMessage(msgButtonNext);
OnClick := @UninsNextButtonOnClick;
end;
// modify Cancel button
CancelButton.Enabled := True;
CancelButton.OnClick := @UninsCancelButtonOnClick;
// create custom page
Page := TNewNotebookPage.Create(UninstallProgressForm);
with Page do begin
Parent := UninstallProgressForm.InnerNotebook;
Notebook := UninstallProgressForm.InnerNotebook;
PageIndex := 0; // first page
end;
// set active (first) page
InnerNotebook.ActivePage := InnerNotebook.Pages[0];
// default page to last page
InstallingPage.PageIndex := InnerNotebook.PageCount-1;
// show form
if ShowModal = mrAbort then Abort;
end;
end;
procedure UninsCancelButtonOnClick(Sender: TObject);
begin
UninstallProgressForm.ModalResult := mrAbort;
end;
function FindWindowEx(Parent, Child: HWND; ClassName, WindowName: PansiChar): HWND; external 'FindWindowExA@user32.dll stdcall';
const
BM_CLICK = $00F5;
var
Timer: TTimer;
msg: string;
Wnd, WndEx: HWND;
procedure OnTimer(Sender: TObject);
begin
Wnd:= FindWindowByWindowName(msg);
if Wnd > 0 then
begin
WndEx:= FindWindowEx(Wnd, 0,'Button', '');
if WndEx > 0 then
begin
PostMessage(WndEx, BM_CLICK, 0, 0);
Timer.Enabled:= False;
end;
end;
end;
function InitializeUninstall:boolean;
//var
// S: String;
begin
//if ActiveLanguage='rus' then
// S:= 'Вы действительно хотите удалить {#GameName}'+#10+'и все компоненты программы?'
//else
// S:= 'Are you sure you want to completely remove {#GameName}'+#10+'and all of its components?';
//if ShowMessageEx(S, '', MB_YESNO, mQuestion) = IDYES then
Result := True;
msg:= SetupMessage(msgUninstallAppFullTitle);
StringChange(msg, '%1', '{#SetupSetting('AppName')}');
OnTimer(nil);
Timer:= TTimer.Create(nil);
with Timer do
begin
OnTimer:= @OnTimer;
Interval:= 1;
Enabled:= True;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep=usPostUninstall then
begin
OnTimer(nil);
Timer:= TTimer.Create(nil);
with Timer do
begin
OnTimer:= @OnTimer;
Interval:= 1;
Enabled:= True;
end;
end;
end;
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
[Code]
function FindWindowEx(Parent, Child: HWND; ClassName, WindowName: PansiChar): HWND; external 'FindWindowExA@user32.dll stdcall';
const
BM_CLICK = $00F5;
var
Timer: TTimer;
msg: string;
Wnd, WndEx: HWND;
procedure UninsNextButtonOnClick(Sender: TObject);
begin
with UninstallProgressForm.InnerNotebook do
begin
ActivePage := Pages[ActivePage.PageIndex + 1];
if ActivePage.PageIndex = PageCount-1 then
begin
TButton(Sender).Hide;
UninstallProgressForm.Close;
end;
end;
end;
procedure OnTimer(Sender: TObject);
begin
Wnd:=FindWindowByWindowName(msg);
if Wnd > 0 then
begin
WndEx := FindWindowEx(Wnd, 0,'Button', '');
if WndEx > 0 then
begin
PostMessage(WndEx, BM_CLICK, 0, 0);
Timer.Enabled:= False;
end;
end;
end;
procedure InitializeUninstallProgressForm();
var
Page: TNewNotebookPage;
UninsNextButton: TButton;
begin
with UninstallProgressForm do
begin
UninsNextButton := TButton.Create(UninstallProgressForm);
with UninsNextButton do
begin
Parent := UninstallProgressForm;
Top := UninstallProgressForm.CancelButton.Top;
Width := UninstallProgressForm.CancelButton.Width;
Height := UninstallProgressForm.CancelButton.Height;
Left := UninstallProgressForm.CancelButton.Left - Width - ScaleX(10);
Caption := SetupMessage(msgButtonNext);
OnClick := @UninsNextButtonOnClick;
end;
CancelButton.Enabled := True;
Page := TNewNotebookPage.Create(UninstallProgressForm);
with Page do begin
Parent := UninstallProgressForm.InnerNotebook;
Notebook := UninstallProgressForm.InnerNotebook;
PageIndex := 0;
end;
InnerNotebook.ActivePage := InnerNotebook.Pages[0];
InstallingPage.PageIndex := InnerNotebook.PageCount-1;
if ShowModal = mrAbort then Abort;
end;
end;
function InitializeUninstall:boolean;
begin
Result := True;
msg:= SetupMessage(msgUninstallAppFullTitle);
StringChange(msg, '%1', '{#SetupSetting('AppName')}');
OnTimer(nil);
Timer:= TTimer.Create(nil);
with Timer do
begin
OnTimer:= @OnTimer;
Interval:= 1;
Enabled:= True;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep=usPostUninstall then
begin
OnTimer(nil);
Timer:= TTimer.Create(nil);
with Timer do
begin
OnTimer:= @OnTimer;
Interval:= 1;
Enabled:= True;
end;
end;
end;