Inno Setup 在自定义页面上放置 image/control
Inno Setup Placing image/control on custom page
我正在尝试在自定义页面上显示图像我可以让自定义页面显示,或者在预定义页面上显示图像但在自定义页面上不显示图像。
我认为 Parent := CustomPage.ID;
有问题。
Parent := WizardForm.SelectTasksPage;
虽然有效。
如何正确执行此操作?
procedure ImageOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('', 'http://test.com', '', '', SW_SHOW, ewNoWait, ErrorCode);
end;
var
CustomPage: TWizardPage;
BtnImage: TBitmapImage;
procedure InitializeWizard;
begin
CustomPage := CreateCustomPage(wpLicense, 'Heading', 'Sub heading.');
ExtractTemporaryFile('image.bmp');
BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
Parent := CustomPage.ID;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
AutoSize := True;
Left := 90;
Top := WizardForm.SelectTasksPage.Top +
WizardForm.SelectTasksPage.Height - Height - 8;
Cursor := crHand;
OnClick := @ImageOnClick;
end;
end;
这就是类型 TNewNotebookPage
的 TWizardPage.Surface
的用途。
with BtnImage do
begin
Parent := CustomPage.Surface;
{ ... }
end;
相关问题:
(关于单选按钮的类似问题,代码更多)
此外,切勿使用绝对坐标和大小。当向导显示在高 DPI/scaled 显示屏上时,您的布局将会中断,这在当今“视网膜”显示屏上很常见。使用 ScaleX
and ScaleY
functions. For the same reason, you should have images with different resolutions ready (see Inno Setup WizardImageFile looks bad with font scaling on Windows 7)。或者至少 scale/stretch 位图。
CustomPage := CreateCustomPage(wpLicense, 'Heading', 'Sub heading.');
ExtractTemporaryFile('image.bmp');
BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
Parent := CustomPage.Surface;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
AutoSize := True;
AutoSize := False;
Height := ScaleY(Height);
Width := ScaleX(Width);
Stretch := True;
Left := ScaleX(90);
Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height -
Height - ScaleY(8);
Cursor := crHand;
OnClick := @ImageOnClick;
end;
100% 缩放 (96 DPI) 的布局:
150% 缩放 (144 DPI) 的布局:
150% 缩放 (144 DPI) 的布局,offset/sizes 缩放和图像拉伸:
你可以使用 Botva2 库
http://krinkels.org/threads/botva2.1931/
如果您看不懂俄语,请使用 google 翻译
你可以使用它创建一些很棒的安装程序
图片 f.e
Botva2 example
[code]
#include "botva2.iss"
var SomeImage : Longint;
procedure InitializeWizard();
begin
{Your Custom page Code Goes Here}
SomeImage := ImgLoad(WizardForm.Handle,'Image.bmp',0,0,854,480,true,true);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
ImgSetVisibility(SomeImage,false);
if (CurPageID = CustomPage.ID) ImgSetVisibility(SomeImage,true);
end;
类似于 Martin Prikryl 的回答。
为了应对不同的DPI设置而放置位图:
- 将您的机器设置为 100% DPI
- 制作一个大小为 (width/height) 的位图以适合您的 InnoSetup page/form
- 获取这些宽度和高度(正确 click/properties 在您的 bmp 文件上)
- 使用下面的代码
- 将您的机器设置为 150% DPI 并创建您的位图以适应 150% DPI 并使用它代替第一个(适合 100% DPI),这样它在 100% 和 200 时看起来都不错%
代码:
WarningImage := TBitmapImage.Create(RisksForm);
WarningImage.Parent := RisksForm;
WarningImage.Bitmap.LoadFromFile(ExpandConstant('{app}')+'uninstall-warning-large.bmp');
WarningImage.Left := ScaleX(24);
WarningImage.Top := ScaleY(120);
WarningImage.Width := ScaleX(544);
WarningImage.Height := ScaleY(211);
WarningImage.Stretch := True;
将位图的宽度更改为 544,将位图的高度更改为 211(来自第 3 步)
Stretch := True 位图比 width/height properties
扩展(如果更小)或收缩(如果更大)
P.S。当然你可以使用多个文件并根据用户 DPI 设置使用一个文件 (DPI settings with Inno Setup),但是位图没有压缩,所以我不喜欢这个主意。
我正在尝试在自定义页面上显示图像我可以让自定义页面显示,或者在预定义页面上显示图像但在自定义页面上不显示图像。
我认为 Parent := CustomPage.ID;
有问题。
Parent := WizardForm.SelectTasksPage;
虽然有效。
如何正确执行此操作?
procedure ImageOnClick(Sender: TObject);
var
ErrorCode: Integer;
begin
ShellExec('', 'http://test.com', '', '', SW_SHOW, ewNoWait, ErrorCode);
end;
var
CustomPage: TWizardPage;
BtnImage: TBitmapImage;
procedure InitializeWizard;
begin
CustomPage := CreateCustomPage(wpLicense, 'Heading', 'Sub heading.');
ExtractTemporaryFile('image.bmp');
BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
Parent := CustomPage.ID;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
AutoSize := True;
Left := 90;
Top := WizardForm.SelectTasksPage.Top +
WizardForm.SelectTasksPage.Height - Height - 8;
Cursor := crHand;
OnClick := @ImageOnClick;
end;
end;
这就是类型 TNewNotebookPage
的 TWizardPage.Surface
的用途。
with BtnImage do
begin
Parent := CustomPage.Surface;
{ ... }
end;
相关问题:
(关于单选按钮的类似问题,代码更多)
此外,切勿使用绝对坐标和大小。当向导显示在高 DPI/scaled 显示屏上时,您的布局将会中断,这在当今“视网膜”显示屏上很常见。使用 ScaleX
and ScaleY
functions. For the same reason, you should have images with different resolutions ready (see Inno Setup WizardImageFile looks bad with font scaling on Windows 7)。或者至少 scale/stretch 位图。
CustomPage := CreateCustomPage(wpLicense, 'Heading', 'Sub heading.');
ExtractTemporaryFile('image.bmp');
BtnImage := TBitmapImage.Create(WizardForm);
with BtnImage do
begin
Parent := CustomPage.Surface;
Bitmap.LoadFromFile(ExpandConstant('{tmp}')+'\image.bmp');
AutoSize := True;
AutoSize := False;
Height := ScaleY(Height);
Width := ScaleX(Width);
Stretch := True;
Left := ScaleX(90);
Top := WizardForm.SelectTasksPage.Top + WizardForm.SelectTasksPage.Height -
Height - ScaleY(8);
Cursor := crHand;
OnClick := @ImageOnClick;
end;
100% 缩放 (96 DPI) 的布局:
150% 缩放 (144 DPI) 的布局:
150% 缩放 (144 DPI) 的布局,offset/sizes 缩放和图像拉伸:
你可以使用 Botva2 库 http://krinkels.org/threads/botva2.1931/ 如果您看不懂俄语,请使用 google 翻译 你可以使用它创建一些很棒的安装程序 图片 f.e Botva2 example
[code]
#include "botva2.iss"
var SomeImage : Longint;
procedure InitializeWizard();
begin
{Your Custom page Code Goes Here}
SomeImage := ImgLoad(WizardForm.Handle,'Image.bmp',0,0,854,480,true,true);
end;
procedure CurPageChanged(CurPageID: Integer);
begin
ImgSetVisibility(SomeImage,false);
if (CurPageID = CustomPage.ID) ImgSetVisibility(SomeImage,true);
end;
类似于 Martin Prikryl 的回答。 为了应对不同的DPI设置而放置位图:
- 将您的机器设置为 100% DPI
- 制作一个大小为 (width/height) 的位图以适合您的 InnoSetup page/form
- 获取这些宽度和高度(正确 click/properties 在您的 bmp 文件上)
- 使用下面的代码
- 将您的机器设置为 150% DPI 并创建您的位图以适应 150% DPI 并使用它代替第一个(适合 100% DPI),这样它在 100% 和 200 时看起来都不错%
代码:
WarningImage := TBitmapImage.Create(RisksForm);
WarningImage.Parent := RisksForm;
WarningImage.Bitmap.LoadFromFile(ExpandConstant('{app}')+'uninstall-warning-large.bmp');
WarningImage.Left := ScaleX(24);
WarningImage.Top := ScaleY(120);
WarningImage.Width := ScaleX(544);
WarningImage.Height := ScaleY(211);
WarningImage.Stretch := True;
将位图的宽度更改为 544,将位图的高度更改为 211(来自第 3 步)
Stretch := True 位图比 width/height properties
扩展(如果更小)或收缩(如果更大)P.S。当然你可以使用多个文件并根据用户 DPI 设置使用一个文件 (DPI settings with Inno Setup),但是位图没有压缩,所以我不喜欢这个主意。