1

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

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

在此处输入图像描述

4

1 回答 1

1

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

它显示了如何在选择目录页面上禁用下一个按钮 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;

这是屏幕截图:

在此处输入图像描述

于 2013-08-18T02:56:49.523 回答