Inno Setup将时间释放添加到按钮 [英] Inno Setup add time release to button

查看:96
本文介绍了Inno Setup将时间释放添加到按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友添加时间按钮下一步或安装"以释放在就绪"页面上

Friends add time "Button Next or Install" to get released on the page "Ready"

15秒释放按钮后的15、14、13、12、11、10、9、8、7、6、5、4次例子

15 second 15,14,13,12,11,10,9,8,7,6,5,4 time after the button is released to click example

推荐答案

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

Since there is no built-in timer in InnoSetup at this time, you'll need to use Windows API for this. Except that, function which will be used here needs a callback function which must be wrapped for instance by the InnoCallback used by the following script.

它显示了如何禁用选择目录页面上的下一个按钮5秒钟,但是您可以简单地更改 DisableNextButton 函数的参数,即以秒为单位的间隔到所需的值以及您可以更改将在哪个页面上使用它.下一个按钮标题中还有剩余时间值:

It shows how to disable the next button on the select directory page for 5 seconds, but you can simply change the parameter of the DisableNextButton function, which is the interval in seconds to value that you want as well as you can change for which page you will use it. There is also the remaining time value in the next button caption:

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

这是屏幕截图:

这篇关于Inno Setup将时间释放添加到按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆