一步安装程序

发布于 2024-11-01 21:14:20 字数 202 浏览 1 评论 0原文

我正在寻找一种在 Inno Setup 中创建单页安装程序的方法,只需看看这个屏幕截图: 一页安装程序图像

谁能给我执行此操作的代码?

或者完全我想在 Inno Setup 中合并页面功能。例如,将选择目录页面与组件页面等合并

I'm looking for a way to create a one page installer in Inno Setup, just look at this screenshot:
One Page Installer Image

Can anyone please give me the codes for doing this?

Or totally I would like to merge pages abilities in Inno Setup. For example merge Select directory page with Components page and etc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

长亭外,古道边 2024-11-08 21:14:20

默认情况下做到这一点并不容易。不过是可以做到的,如下代码
生成了这样一个页面。在此处输入图像描述

[Setup]
AppName=Test
AppVersion=1.5
DefaultDirName={code:AppDir}
;Disable all of the default wizard pages
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyMemo=yes
DisableReadyPage=yes
DisableStartupPrompt=yes
DisableWelcomePage=yes

;May want this, after install.
DisableFinishedPage=no

[Messages]
ButtonNext=Install

[Files]
Source:"e:\test.txt"; DestDir: "{app}"
Source:"e:\test.txt"; DestDir: "{app}"; DestName: "test1.txt"; Check: Option1;
Source:"e:\test.txt"; DestDir: "{app}"; DestName: "test2.txt"; Check: Option2;


[Code]

var
 MainPage : TWizardPage;
 edtFolderToInstall : TEdit;
 InstallLocation : String;
 Opt1, Opt2 : Boolean;
 ChkOption1 :  TCheckBox;
 ChkOption2 :  TCheckBox;


function  AppDir(Param: String): String;
begin
  // Set Default if not set.
  if InstallLocation = '' then
     InstallLocation := ExpandConstant('{pf}') + 'test';
  result := InstallLocation;
end;

function Option1 : Boolean;
begin
  result := Opt1;
end;

function Option2 : Boolean;
begin
  result := Opt2;
end;

procedure BrowseClick(Sender : TObject);
var
 Dir : String;
begin
  Dir := edtFolderToInstall.Text;
  if BrowseForFolder('Select Folder',Dir,false) then
    edtFolderToInstall.Text := Dir;
end;

procedure InitializeWizard();
var
 lblFolderToInstall : TLabel;
 btnFolderToInstall : TButton;


begin
 MainPage := CreateCustomPage(wpWelcome,'Setup - Test App Name','This will install "Test App Name" to your computer');
 lblFolderToInstall := TLabel.Create(MainPage);
 lblFolderToInstall.Parent := MainPage.Surface;
 lblFolderToInstall.Top := 10;
 lblFolderToInstall.Left := 10;
 lblFolderToInstall.Caption := 'If you would like to select a different folder, Click Browse.'


 edtFolderToInstall := TEdit.Create(MainPage);
 edtFolderToInstall.Parent := MainPage.Surface;

 edtFolderToInstall.Top := 25;
 edtFolderToInstall.Left := 10;
 edtFolderToInstall.Width := 250;
 edtFolderToInstall.Text :=  WizardDirValue;


 btnFolderToInstall := TButton.Create(MainPage);
 btnFolderToInstall.Parent := MainPage.Surface;
 btnFolderToInstall.top := 25;
 btnFolderToInstall.Left := 275;
 btnfolderToInstall.Caption := 'Browse...';
 btnFolderToInstall.OnClick := @BrowseClick;

 ChkOption1 :=  TCheckBox.Create(MainForm);
 ChkOption1.Parent := MainPage.Surface;
 ChkOption1.Top := 50;
 ChkOption1.Left := 10;
 ChkOption1.Caption := 'Option 1';

 ChkOption2 :=  TCheckBox.Create(MainForm);
 ChkOption2.Parent := MainPage.Surface;
 ChkOption2.Top := 75;
 ChkOption2.Left := 10;
 ChkOption2.Caption := 'Option 2';



end;


function NextButtonClick(CurPageID: Integer): Boolean;
begin
  result := True;
  // Next pressed, better make sure selected items are correct.
  if CurPageId = MainPage.ID then
  begin
     InstallLocation := edtFolderToInstall.Text;
     Opt1 := ChkOption1.Checked;
     Opt2 := ChkOption2.Checked;
  end;
end;

为了实现这一点,我使用 {code:AppDir} 作为默认目录。这告诉 InnoSetup 使用函数 AppDir 来检索安装目录。然后我可以使用我的自定义对话框进行设置。

我必须在 [Files] 中使用 Check,而不是使用 [Components] 和/或 [Tasks]部分。

It's not easy to do by default. But it can be done, the following code
produced a page like this one.enter image description here

[Setup]
AppName=Test
AppVersion=1.5
DefaultDirName={code:AppDir}
;Disable all of the default wizard pages
DisableDirPage=yes
DisableProgramGroupPage=yes
DisableReadyMemo=yes
DisableReadyPage=yes
DisableStartupPrompt=yes
DisableWelcomePage=yes

;May want this, after install.
DisableFinishedPage=no

[Messages]
ButtonNext=Install

[Files]
Source:"e:\test.txt"; DestDir: "{app}"
Source:"e:\test.txt"; DestDir: "{app}"; DestName: "test1.txt"; Check: Option1;
Source:"e:\test.txt"; DestDir: "{app}"; DestName: "test2.txt"; Check: Option2;


[Code]

var
 MainPage : TWizardPage;
 edtFolderToInstall : TEdit;
 InstallLocation : String;
 Opt1, Opt2 : Boolean;
 ChkOption1 :  TCheckBox;
 ChkOption2 :  TCheckBox;


function  AppDir(Param: String): String;
begin
  // Set Default if not set.
  if InstallLocation = '' then
     InstallLocation := ExpandConstant('{pf}') + 'test';
  result := InstallLocation;
end;

function Option1 : Boolean;
begin
  result := Opt1;
end;

function Option2 : Boolean;
begin
  result := Opt2;
end;

procedure BrowseClick(Sender : TObject);
var
 Dir : String;
begin
  Dir := edtFolderToInstall.Text;
  if BrowseForFolder('Select Folder',Dir,false) then
    edtFolderToInstall.Text := Dir;
end;

procedure InitializeWizard();
var
 lblFolderToInstall : TLabel;
 btnFolderToInstall : TButton;


begin
 MainPage := CreateCustomPage(wpWelcome,'Setup - Test App Name','This will install "Test App Name" to your computer');
 lblFolderToInstall := TLabel.Create(MainPage);
 lblFolderToInstall.Parent := MainPage.Surface;
 lblFolderToInstall.Top := 10;
 lblFolderToInstall.Left := 10;
 lblFolderToInstall.Caption := 'If you would like to select a different folder, Click Browse.'


 edtFolderToInstall := TEdit.Create(MainPage);
 edtFolderToInstall.Parent := MainPage.Surface;

 edtFolderToInstall.Top := 25;
 edtFolderToInstall.Left := 10;
 edtFolderToInstall.Width := 250;
 edtFolderToInstall.Text :=  WizardDirValue;


 btnFolderToInstall := TButton.Create(MainPage);
 btnFolderToInstall.Parent := MainPage.Surface;
 btnFolderToInstall.top := 25;
 btnFolderToInstall.Left := 275;
 btnfolderToInstall.Caption := 'Browse...';
 btnFolderToInstall.OnClick := @BrowseClick;

 ChkOption1 :=  TCheckBox.Create(MainForm);
 ChkOption1.Parent := MainPage.Surface;
 ChkOption1.Top := 50;
 ChkOption1.Left := 10;
 ChkOption1.Caption := 'Option 1';

 ChkOption2 :=  TCheckBox.Create(MainForm);
 ChkOption2.Parent := MainPage.Surface;
 ChkOption2.Top := 75;
 ChkOption2.Left := 10;
 ChkOption2.Caption := 'Option 2';



end;


function NextButtonClick(CurPageID: Integer): Boolean;
begin
  result := True;
  // Next pressed, better make sure selected items are correct.
  if CurPageId = MainPage.ID then
  begin
     InstallLocation := edtFolderToInstall.Text;
     Opt1 := ChkOption1.Checked;
     Opt2 := ChkOption2.Checked;
  end;
end;

To pull this off, I use {code:AppDir} as the default directory. This tells InnoSetup to use the function AppDir to retrieve the installation directory. I then can set it using my custom dialog.

Instead of using [Components] and/or [Tasks] I have to use Check in the [Files] Section.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文