0

禁用同一页面上的两个按钮我尝试了几种方法,但没有得到更接近这个示例不正确 [button next = with time] [button back= no time (only disable)] 帮助找到错误绑定

 [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;
4

1 回答 1

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;
于 2013-08-25T14:52:11.633 回答