Inno Setup 在自定义表单标题栏上使用不同的图标
Inno Setup use a different icon on a custom form title bar
默认情况下,自定义表单在标题栏中使用与主 WizardForm
相同的图标,即 SetupIconFile
。有什么方法可以在标题栏上为自定义表单提供不同的图标吗?
[Code]
var
CustomWindowForm: TForm;
{ Create and show the Custom window }
procedure ShowCustomWindow();
begin
CustomWindowForm := TForm.Create(WizardForm);
with CustomWindowForm do
begin
BorderStyle := bsSingle;
Position := poOwnerFormCenter;
Caption := 'Window Title';
ClientWidth := ScaleX(400);
ClientHeight := ScaleY(400);
Show;
end;
end;
我需要的是 TForm
的 Icon
属性 之类的东西,但似乎没有,而且我在任何地方都找不到这方面的任何信息。
您必须使用 WinAPI,尤其是 LoadImage
function and WM_SETICON
message:
[Files]
Source: "custom.ico"; Flags: dontcopy
[Code]
const
IMAGE_ICON = 1;
LR_LOADFROMFILE = ;
WM_SETICON = ;
ICON_SMALL = 0;
function LoadImage(
hInst: Integer; ImageName: string; ImageType: UINT; X, Y: Integer;
Flags: UINT): THandle; external 'LoadImageW@User32.dll stdcall';
procedure CustomFormShow(Sender: TObject);
var
Icon: THandle;
begin
ExtractTemporaryFile('custom.ico');
Icon := LoadImage(
0, ExpandConstant('{tmp}\custom.ico'), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
SendMessage(TForm(Sender).Handle, WM_SETICON, ICON_SMALL, Icon);
end;
var
CustomWindowForm: TForm;
{ Create and show the custom window }
procedure ShowCustomWindow();
begin
CustomWindowForm := TForm.Create(WizardForm);
with CustomWindowForm do
begin
{ your code }
OnShow := @CustomFormShow;
Show;
end;
end;
(该代码适用于 Inno Setup 的 Unicode 版本——Inno Setup 6 的唯一版本)
默认情况下,自定义表单在标题栏中使用与主 WizardForm
相同的图标,即 SetupIconFile
。有什么方法可以在标题栏上为自定义表单提供不同的图标吗?
[Code]
var
CustomWindowForm: TForm;
{ Create and show the Custom window }
procedure ShowCustomWindow();
begin
CustomWindowForm := TForm.Create(WizardForm);
with CustomWindowForm do
begin
BorderStyle := bsSingle;
Position := poOwnerFormCenter;
Caption := 'Window Title';
ClientWidth := ScaleX(400);
ClientHeight := ScaleY(400);
Show;
end;
end;
我需要的是 TForm
的 Icon
属性 之类的东西,但似乎没有,而且我在任何地方都找不到这方面的任何信息。
您必须使用 WinAPI,尤其是 LoadImage
function and WM_SETICON
message:
[Files]
Source: "custom.ico"; Flags: dontcopy
[Code]
const
IMAGE_ICON = 1;
LR_LOADFROMFILE = ;
WM_SETICON = ;
ICON_SMALL = 0;
function LoadImage(
hInst: Integer; ImageName: string; ImageType: UINT; X, Y: Integer;
Flags: UINT): THandle; external 'LoadImageW@User32.dll stdcall';
procedure CustomFormShow(Sender: TObject);
var
Icon: THandle;
begin
ExtractTemporaryFile('custom.ico');
Icon := LoadImage(
0, ExpandConstant('{tmp}\custom.ico'), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
SendMessage(TForm(Sender).Handle, WM_SETICON, ICON_SMALL, Icon);
end;
var
CustomWindowForm: TForm;
{ Create and show the custom window }
procedure ShowCustomWindow();
begin
CustomWindowForm := TForm.Create(WizardForm);
with CustomWindowForm do
begin
{ your code }
OnShow := @CustomFormShow;
Show;
end;
end;
(该代码适用于 Inno Setup 的 Unicode 版本——Inno Setup 6 的唯一版本)