Inno Setup为按钮添加时间释放

时间:2013-08-18 01:08:53

标签: inno-setup

友 添加时间“按钮下一步或安装”以获得发布 在“准备好”页面上

15秒 15,14,13,12,11,10,9,8,7,6,5,4按钮释放后单击时间 示例

enter image description here

1 个答案:

答案 0 :(得分:1)

由于InnoSetup目前没有内置计时器,因此您需要使用Windows API。除此之外,这里使用的函数需要一个回调函数,该函数必须由以下脚本使用的InnoCallback包装。

它显示了如何禁用select目录页面上的下一个按钮5秒钟,但是您可以简单地更改DisableNextButton函数的参数,这是您想要的值的间隔(以秒为单位)以及您可以更改您将使用它的页面。下一个按钮标题中还有剩余时间值:

[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.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 DisableNextButton(Timeout: Integer);
var
  TimerCallback: LongWord;
begin
  Counter := Timeout;  
  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
    DisableNextButton(5);
end;

以下是截图:

enter image description here