gpt4 book ai didi

inno-setup - Inno Setup 会记住下次安装中的自定义复选框状态

转载 作者:行者123 更新时间:2023-12-03 11:23:33 27 4
gpt4 key购买 nike

当用户下次运行安装程序或重新安装时,是否有办法记住自定义页面上自定义复选框的状态(选中/取消选中)?类似于经典的 ComponentsList 中的东西。

安装程序有 cca​​. 7 个自定义页面上有 100 个选项(自定义复选框/单选按钮)。如果用户在之前的安装中预先定义了他们的选择,那就太好了。

我的代码如下所示:

[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program

[Files]
Source: ReadMe1.rtf; Flags: dontcopy
Source: ReadMe2.rtf; Flags: dontcopy
Source: ReadMe3.rtf; Flags: dontcopy

Source: Image1.bmp; Flags: dontcopy
Source: Image2.bmp; Flags: dontcopy
Source: Image3.bmp; Flags: dontcopy

Source: Files\*; DestDir: {app}\add; Flags: ignoreversion recursesubdirs createallsubdirs; Check: CheckedBox(2)

[Code]
var
Page: TWizardPage;
ListBox: TNewCheckListBox;
Memo: TRichEditViewer;
CheckLabel: TLabel;
MouseY: integer;
BitmapImage: TBitmapImage;
InfoBmp: array of TBitmap;

function CheckedBox(ItemNumber: integer): Boolean;
begin
Result:= ListBox.Checked[ItemNumber];
end;

procedure CheckOnClick (Sender: TObject);
begin
if MouseY < ListBox.Items.Count then
begin
ListBox.Checked[MouseY]:= Not(ListBox.Checked[MouseY]);
end;
end;

procedure CheckMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
MouseY:= Y/ScaleY(16);
if MouseY < ListBox.Items.Count then
begin
Memo.RTFText:= TStrings(ListBox.ItemObject[MouseY]).Text;
BitmapImage.Bitmap:= InfoBmp[MouseY];
end;
end;

procedure InitializeWizard();
var
i: integer;
begin
ExtractTemporaryFile('ReadMe1.rtf'); ˙
ExtractTemporaryFile('ReadMe2.rtf');
ExtractTemporaryFile('ReadMe3.rtf');
ExtractTemporaryFile('Image1.bmp');
ExtractTemporaryFile('Image2.bmp');
ExtractTemporaryFile('Image3.bmp');

Page:=CreateCustomPage(wpWelcome, 'Title', 'Description')

ListBox:= TNewCheckListBox.Create(Page);
with ListBox do
begin
Left := 15
Top := 0
Width := 200
Height := 149
Parent := Page.Surface
AddCheckBox('Global', '', 0, True, True, True, True, TStringList.Create);
AddCheckBox('Option 1', '', 1, True, True, False, True, TStringList.Create);
AddCheckBox('Option 2', '', 1, True, True, False, True, TStringList.Create);

TStrings(ItemObject[0]).LoadFromFile(ExpandConstant('{tmp}\ReadMe1.rtf'));
TStrings(ItemObject[1]).LoadFromFile(ExpandConstant('{tmp}\ReadMe2.rtf'));
TStrings(ItemObject[2]).LoadFromFile(ExpandConstant('{tmp}\ReadMe3.rtf'));
end;

Memo:= TRichEditViewer.Create(Page);
with Memo do
begin
Left := ListBox.Left + ListBox.Width + 8;
Top := ListBox.Top;
Width := ListBox.Width;
Height := ListBox.Height;
Color := clBtnFace;
Enabled := False;
BorderStyle := bsNone;
Parent := Page.Surface;
end;

CheckLabel:= TLabel.Create(Page);
with CheckLabel do
begin
Width :=ListBox.Width;
Height :=ListBox.Height;
Autosize :=False;
Transparent :=True;
OnMouseMove :=@CheckMouseMove;
OnClick :=@CheckOnClick;
Parent :=ListBox;
Cursor := 1;
end;

BitmapImage := TBitmapImage.Create(Page);
with BitmapImage do
begin
AutoSize := True;
Left := ListBox.Left;
Top := ListBox.Top + ListBox.Height + 8;
Width := ListBox.Width;
Height := 32;
Parent := Page.Surface;
end;

for i:=0 to ListBox.Items.Count - 1 do
begin
SetArrayLength(InfoBmp, i+1);
InfoBmp[i]:= TBitmap.Create;
end;

InfoBmp[0].LoadFromFile(ExpandConstant('{tmp}\Image1.bmp'));
InfoBmp[1].LoadFromFile(ExpandConstant('{tmp}\Image2.bmp'));
InfoBmp[2].LoadFromFile(ExpandConstant('{tmp}\Image3.bmp'));
end;

最佳答案

关于inno-setup - Inno Setup 会记住下次安装中的自定义复选框状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26518663/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com