在同一页面上禁用两个按钮 我尝试了几种方法,但没有得到更接近这个例子不正确 [按钮next = with time] [按钮返回=没有时间(仅禁用)] 帮助找到错误界限
[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 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL;
external 'KillTimer@user32.dll 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;
答案 0 :(得分:1)
要禁用这两个按钮,指定时间的下一个按钮和后退按钮,只有下一个按钮会有倒数计时器标题,您可以使用基于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 'SetTimer@user32.dll stdcall';
function KillTimer(hWnd: HWND; uIDEvent: UINT): BOOL;
external 'KillTimer@user32.dll 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;