Reputation: 183
Disable two buttons on the same page I tried several ways but did not get the closer this example was not correct [button next = with time] [button back= no time (only disable)] help to find the error bound
[Code]
var
Counter: Integer;
TimerID: Integer;
type
TTimerProc = procedure(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
external 'wrapcallback@files:InnoCallback.dll stdcall';
function SetTimer(hWnd: HWND; nIDEvent, uElapse: UINT;
lpTimerFunc: UINT): UINT; external '[email protected] stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL;
external '[email protected] stdcall';
procedure OnTimerTick(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
begin
Counter := Counter - 1;
begin
Counter := Counter - 1;
if Counter <= 0 then
begin
WizardForm.NextButton.Enabled := True;
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall);
if TimerID <> 0 then
KillTimer(0, TimerID);
end
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall) +
IntToStr(Counter);
end;
// begin
WizardForm.BackButton.Enabled := True;
if TimerID <> 0 then
begin
if KillTimer(0, TimerID) then
TimerID := 0;
end;
end;
procedure DisableNextButton(Timeout: Integer);
var
TimerCallback: LongWord;
begin
Counter := Timeout;
WizardForm.NextButton.Enabled := False;
WizardForm.NextButton.Caption := SetupMessage(msgButtonInstall) + IntToStr(Counter);
TimerCallback := WrapTimerProc(@OnTimerTick, 4);
TimerID := SetTimer(0, 0, 1000, TimerCallback);
end;
procedure DisableBackButton(Timeout: UINT);
var
TimerCallback: LongWord;
begin
WizardForm.BackButton.Enabled := False;
TimerCallback := WrapTimerProc(@OnTimerTick, 4);
TimerID := SetTimer(0, 0, Timeout, TimerCallback);
end;
procedure CurPageChanged5(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
DisableNextButton(10);
end;
procedure CurPageChanged6(CurPageID: Integer);
begin
if CurPageID = wpSelectTasks then
DisableBackButton(5000);
end;
Upvotes: 0
Views: 1512
Reputation: 76693
To disable both buttons, the next button and back button for a specified time while only next button will have the countdown timer caption, you can use the following modified script based on this post
:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
[Files]
Source: "InnoCallback.dll"; DestDir: "{tmp}"; Flags: dontcopy
[Code]
var
Counter: Integer;
TimerID: Integer;
type
TTimerProc = procedure(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord;
external 'wrapcallback@files:InnoCallback.dll stdcall';
function SetTimer(hWnd: HWND; nIDEvent, uElapse: UINT;
lpTimerFunc: UINT): UINT; external '[email protected] stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL;
external '[email protected] stdcall';
procedure OnTimerTick(Wnd: HWND; Msg: UINT; TimerID: UINT_PTR;
SysTime: DWORD);
begin
Counter := Counter - 1;
if Counter <= 0 then
begin
WizardForm.BackButton.Enabled := True;
WizardForm.NextButton.Enabled := True;
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext);
if TimerID <> 0 then
KillTimer(0, TimerID);
end
else
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext) +
IntToStr(Counter);
end;
procedure DisableNavigateButtons(Timeout: Integer);
var
TimerCallback: LongWord;
begin
Counter := Timeout;
WizardForm.BackButton.Enabled := False;
WizardForm.NextButton.Enabled := False;
WizardForm.NextButton.Caption := SetupMessage(msgButtonNext) +
IntToStr(Counter);
TimerCallback := WrapTimerProc(@OnTimerTick, 4);
TimerID := SetTimer(0, 0, 1000, TimerCallback);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpSelectDir then
DisableNavigateButtons(5);
end;
Upvotes: 1