以下代码要求用户使用CreateInputOptionPage选择是或否,如果用户选择“是”,则下面的代码要提示消息“是已选择”,如果用户选择“否”,则提示“未选择”。
我的代码似乎无效。请帮忙。
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=D:\authorized\Builds\Custom wizard
[Code]
//#include "Solo - detectVersionFInal.iss"
var
UsagePage: TInputOptionWizardPage;
InstallationTypeIsClient: boolean;
Initialize:boolean;
procedure InitializeWizard;
begin
{ Create the pages }
UsagePage := CreateInputOptionPage(wpWelcome,
'KMOffline setup information', 'How would you like to install KMOffline?',
'Would you like to insall KMOffline as a service?.',
True, False);
UsagePage.Add('Yes');
UsagePage.Add('No');
UsagePage.Values[0] := False;
end;
function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID=UsagePage.ID then
begin
InstallationTypeIsClient := UsagePage.Values[0];
MsgBox('InstallationTypeIsClient value is ' + Format('%d', [InstallationTypeIsClient]), mbInformation, MB_OK);
end;
Result := True;
end;
function InitializeSetup: Boolean;
var
begin
if (InstallationTypeIsClient=True) then
begin
MsgBox('Yes selected' + Format('%d', [InstallationTypeIsClient]), mbInformation, MB_OK);
end;
if (InstallationTypeIsClient=False) then
begin
MsgBox('No selected ' + Format('%d', [InstallationTypeIsClient]), mbInformation, MB_OK);
end;
Result := True;
end;
答案 0 :(得分:2)
只需将您的代码从InitializeSetup
移至NextButtonClick
:
function NextButtonClick(CurPageID: Integer): Boolean;
begin
if CurPageID = UsagePage.ID then
begin
if UsagePage.Values[0] then
begin
MsgBox('Yes selected', mbInformation, MB_OK);
end
else
begin
MsgBox('No selected', mbInformation, MB_OK);
end;
end;
Result := True;
end;