How to use native Windows icons like old Inno versions

190 views
Skip to first unread message

Bruno Lopes

unread,
Nov 3, 2024, 10:38:28 AM11/3/24
to innosetup
The most recent Inno version uses this custom folder icon by default:

Captura de tela 2024-11-03 121538.png

I would like, however, to use Windows native icon, like old Inno versions:

Captura de tela 2024-11-02 113359.png

How can I do this?

Bruno Lopes

unread,
Mar 29, 2025, 10:38:33 AMMar 29
to innosetup
The line responsible to forcing that icon is:  issrc/Projects/Src/Setup.WizardForm.pas at 2181c1c1410720bb27ca4b9fdb611bc6aa222782 · jrsoftware/issrc

SelectDirBitmapImage.InitializeFromIcon(HInstance, 'Z_DIRICON', SelectDirPage.Color, [32, 48, 64]);

Gavin Lambert

unread,
Mar 30, 2025, 9:36:07 PMMar 30
to innosetup
On Sunday, March 30, 2025 at 3:38:33 AM UTC+13 Bruno Lopes wrote:
SelectDirBitmapImage.InitializeFromIcon(HInstance, 'Z_DIRICON', SelectDirPage.Color, [32, 48, 64]);

That control is visible to [Code] (via WizardForm), so you can change it to an icon of your choice in InitializeWizard. 

Bruno Lopes

unread,
Apr 4, 2025, 9:13:15 AMApr 4
to innosetup
What would be the syntax to do that? If I try to use := I get this at build-time:

read-only property.
Compile aborted.

If I try to use a handle, I get this at runtime:

Captura de tela 2025-04-04 094543.png

If I try to emulate InitializeFromIcon creating a function. I get "unknow identifier"

Eivind Bakkestuen

unread,
Apr 4, 2025, 4:26:51 PMApr 4
to inno...@googlegroups.com
Please show the actual code causing those errors?

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/172a433a-a704-410b-a42b-0acfcf707a03n%40googlegroups.com.

Bruno Lopes

unread,
Apr 5, 2025, 3:06:57 PMApr 5
to innosetup
The code that triggers "read-only property. Compile aborted" error is:

function Dir_Icon(): Integer;
var TypRect: TRect;
Icon: THandle;
TypImg: TBitmapImage;
begin
TypRect.Left := 0;
TypRect.Top := 0;
TypRect.Right := GetSystemMetrics(SM_CXICON);
TypRect.Bottom := GetSystemMetrics(SM_CYICON);

Icon := ExtractIcon(0,'imageres.dll',3)
with TypImg do
begin
Left := ScaleX(MWU_LEFTBORDER);
Top := ScaleY(MWU_TOPBORDER);
Center := False;
Stretch := False;
AutoSize := True;
Bitmap.Width := GetSystemMetrics(SM_CXICON);
Bitmap.Height := GetSystemMetrics(SM_CYICON);
Bitmap.Canvas.Brush.Color := TPanel(Parent).Color;
Bitmap.Canvas.FillRect(TypRect);
DrawIcon(Bitmap.Canvas.Handle,0,0,Icon);
end;
//DestroyIcon(Icon); //not needed with LR_SHARED or with LoadIcon
end;

procedure InitializeWizard();
begin
        WizardForm.SelectDirBitmapImage = Dir_Icon();
end;

---

The code that triggers "Cannot cast an object" error is:

procedure Dir_Icon(TypImg: TBitmapImage);
var TypRect: TRect;
Icon: THandle;
begin
TypRect.Left := 0;
TypRect.Top := 0;
TypRect.Right := GetSystemMetrics(SM_CXICON);
TypRect.Bottom := GetSystemMetrics(SM_CYICON);

Icon := ExtractIcon(0,'imageres.dll',3)
with TypImg do
begin
Left := ScaleX(MWU_LEFTBORDER);
Top := ScaleY(MWU_TOPBORDER);
Center := False;
Stretch := False;
AutoSize := True;
Bitmap.Width := GetSystemMetrics(SM_CXICON);
Bitmap.Height := GetSystemMetrics(SM_CYICON);
Bitmap.Canvas.Brush.Color := TPanel(Parent).Color;
Bitmap.Canvas.FillRect(TypRect);
DrawIcon(Bitmap.Canvas.Handle,0,0,Icon);
end;
//DestroyIcon(Icon); //not needed with LR_SHARED or with LoadIcon
end;

procedure InitializeWizard();
begin
        Dir_Icon(WizardForm.SelectDirBitmapImage);
end;

---

I am omitting some things because some variables and functions are declared on: build/windows/installer/util_MessageWithURL.isi · master · GNOME / GIMP · GitLab

Eivind Bakkestuen

unread,
Apr 5, 2025, 6:34:16 PMApr 5
to inno...@googlegroups.com
"
        WizardForm.SelectDirBitmapImage = Dir_Icon();
"

Don't try to change the readonly property?

SelectDirBitmapImage is a TBitmapImage.  TBitmapImage has a Bitmap property that is read/write.



Reply all
Reply to author
Forward
0 new messages