Recent

Author Topic: How to assign an icon for subforms and dialogs?  (Read 301 times)

Vodnik

  • Jr. Member
  • **
  • Posts: 79
How to assign an icon for subforms and dialogs?
« on: February 11, 2019, 10:00:27 pm »
I'm using TImageList for assigning icons for controls.
For Forms I can see only Icon property. Is it possible to assign icon for a Form from ImageList?
For Dialogs (e.g. TSaveDialog) I didn't find any property to assign icon. Is it possible anyway?

wp

  • Hero Member
  • *****
  • Posts: 5367
Re: How to assign an icon for subforms and dialogs?
« Reply #1 on: February 11, 2019, 10:23:20 pm »
This code with an image list populated by some png images works for me:
Code: Pascal  [Select]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   ImageList1.GetIcon(0, Icon);
  4. end;

The SaveDialog gets the icon from the form from which it is opened.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Blaazen

  • Hero Member
  • *****
  • Posts: 2755
  • POKE 54296,15
    • Eye-Candy Controls
Re: How to assign an icon for subforms and dialogs?
« Reply #2 on: February 11, 2019, 10:43:11 pm »
I use this code for ImageLists with more resolutions, when I need higher (non-default) resolution:
Code: Pascal  [Select]
  1.   aBMP:=TBitmap.Create;
  2.   ImageList.ResolutionForPPI[cIconWidth, 96, 1].GetBitmap(aImageIndex, aBMP);
  3.   FormXYZ.Icon.Assign(aBMP);
  4.   aBMP.Free;
Maybe there's a simpler way.
Lazarus 2.1.0 r59757M FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.11.2, Plasma 5.14.2
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/