在 Inno Setup 中循环命令或函数直到条件变为真
Loop Commands or Functions Until a Condition becomes True in Inno Setup
当 运行 我的程序安装程序使用 Inno Setup 创建时,我想向我的用户显示一个漂亮的欢迎动画 GIF。
我想使用 Isgsg.dll
为订单显示一些 PNG 图像(因为 Inno Setup 尚不支持显示动画 GIF),直到安装程序完成对我大量代码的初始化。
我写了一个代码来按顺序显示这些 PNG 图像,但在显示最后一个图像后它停止了。
我需要在之前显示的最后一个 PNG 图像之后继续显示第一个 PNG 图像。
如果安装程序已初始化,(我的意思是如果 WizardForm
可见)循环过程应该停止。
我为显示这些 PNG 图像而编写的代码:
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
if Result = True then begin
ExtractTemporaryFile('Welcome1.png');
ExtractTemporaryFile('Welcome2.png');
ExtractTemporaryFile('Welcome3.png');
ExtractTemporaryFile('Welcome4.png');
ExtractTemporaryFile('Welcome5.png');
ExtractTemporaryFile('Welcome6.png');
ExtractTemporaryFile('Welcome7.png');
<<< 循环应该从这里开始 >>>
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome1.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome2.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome3.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome4.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome5.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome6.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome7.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
<<< 如果 WizardForm
不可见,应从此处继续循环,否则应停止循环 >>>
...
end;
我怎样才能做到这一点?
更新问题
我不明白为什么此代码不起作用。
此 DLL 需要 PNG 文件的文件名作为 AnsiString
。
但是我提供了 String
。
这是出错了还是这里有任何其他 Synatx 错误导致它不起作用?
Not Working
表示那些显示循环过程的 PNG 图像不起作用。
我尝试添加的代码使用 Repeat Until
执行此条件循环:
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
IMessageHandler: TForm;
X: Integer;
ErrorCode: Integer;
LblWait: TLabel;
if Result := True then begin
DlgWait := TForm.Create(nil);
DlgWait.Hide;
begin
Order:=1;
Repeat
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome+IntToStr(Order)+.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
Order:=Order+1;
Until FileExists(ExpandConstant('{tmp}\Welcome+IntToStr(Order)+.png')) = False;
end;
end;
是否有任何语法错误?
但是编译器没有给出任何编译器警告或错误。
提前致谢。
到达终点后,您需要重置计数器。这样的事情应该让你开始。 (注意:未经测试 - 我在这台机器上没有 InnoSetup。将 until
中的测试替换为适合检测 WizardForm 可见的任何内容。)
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
IMessageHandler: TForm;
X: Integer;
ErrorCode: Integer;
LblWait: TLabel;
const
NumImages = 7;
begin
if Result then
begin
DlgWait := TForm.Create(nil);
DlgWait.Hide;
Order := 1;
repeat
ShowSplashScreen(DlgWait.Handle, ExpandConstant('{tmp}\Welcome' + IntToStr(Order) + '.png'), 0250, 1000, 0250, 0,255, True, $FFFFFF, 10);
Order := Order + 1;
if Order > NumImages then
Order := 1;
until WizardForm.Visible;
end;
end;
当 运行 我的程序安装程序使用 Inno Setup 创建时,我想向我的用户显示一个漂亮的欢迎动画 GIF。
我想使用 Isgsg.dll
为订单显示一些 PNG 图像(因为 Inno Setup 尚不支持显示动画 GIF),直到安装程序完成对我大量代码的初始化。
我写了一个代码来按顺序显示这些 PNG 图像,但在显示最后一个图像后它停止了。
我需要在之前显示的最后一个 PNG 图像之后继续显示第一个 PNG 图像。
如果安装程序已初始化,(我的意思是如果 WizardForm
可见)循环过程应该停止。
我为显示这些 PNG 图像而编写的代码:
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
if Result = True then begin
ExtractTemporaryFile('Welcome1.png');
ExtractTemporaryFile('Welcome2.png');
ExtractTemporaryFile('Welcome3.png');
ExtractTemporaryFile('Welcome4.png');
ExtractTemporaryFile('Welcome5.png');
ExtractTemporaryFile('Welcome6.png');
ExtractTemporaryFile('Welcome7.png');
<<< 循环应该从这里开始 >>>
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome1.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome2.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome3.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome4.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome5.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome6.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome7.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
<<< 如果 WizardForm
不可见,应从此处继续循环,否则应停止循环 >>>
...
end;
我怎样才能做到这一点?
更新问题
我不明白为什么此代码不起作用。
此 DLL 需要 PNG 文件的文件名作为 AnsiString
。
但是我提供了 String
。
这是出错了还是这里有任何其他 Synatx 错误导致它不起作用?
Not Working
表示那些显示循环过程的 PNG 图像不起作用。
我尝试添加的代码使用 Repeat Until
执行此条件循环:
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
IMessageHandler: TForm;
X: Integer;
ErrorCode: Integer;
LblWait: TLabel;
if Result := True then begin
DlgWait := TForm.Create(nil);
DlgWait.Hide;
begin
Order:=1;
Repeat
ShowSplashScreen(DlgWait.Handle,ExpandConstant('{tmp}\Welcome+IntToStr(Order)+.png'),0250,1000,0250,0,255,True,$FFFFFF,10);
Order:=Order+1;
Until FileExists(ExpandConstant('{tmp}\Welcome+IntToStr(Order)+.png')) = False;
end;
end;
是否有任何语法错误?
但是编译器没有给出任何编译器警告或错误。
提前致谢。
到达终点后,您需要重置计数器。这样的事情应该让你开始。 (注意:未经测试 - 我在这台机器上没有 InnoSetup。将 until
中的测试替换为适合检测 WizardForm 可见的任何内容。)
function InitializeSetup(): Boolean;
var
DlgWait: TForm;
IMessageHandler: TForm;
X: Integer;
ErrorCode: Integer;
LblWait: TLabel;
const
NumImages = 7;
begin
if Result then
begin
DlgWait := TForm.Create(nil);
DlgWait.Hide;
Order := 1;
repeat
ShowSplashScreen(DlgWait.Handle, ExpandConstant('{tmp}\Welcome' + IntToStr(Order) + '.png'), 0250, 1000, 0250, 0,255, True, $FFFFFF, 10);
Order := Order + 1;
if Order > NumImages then
Order := 1;
until WizardForm.Visible;
end;
end;