Recent

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

Vodnik

  • Full Member
  • ***
  • Posts: 210
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: 11912
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.

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • 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.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
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/

 

TinyPortal © 2005-2018