Recent

Author Topic: {SOLVED] Replace an image in a TImageList  (Read 1309 times)

petevick

  • Sr. Member
  • ****
  • Posts: 337
{SOLVED] Replace an image in a TImageList
« on: March 09, 2023, 12:41:31 pm »
I have someting in mind I'd like to do that would require me to replace, in a TImageList, an image at a given ImageIndex with another image at runtime. Would this be possible ?? I've searched online and couldn't find anything definitive.
« Last Edit: March 10, 2023, 01:34:10 pm by petevick »
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Replace an image in a TImageList
« Reply #1 on: March 09, 2023, 12:53:17 pm »
Code: Pascal  [Select][+][-]
  1. type
  2.   TCustomImageList = class(TLCLComponent)
  3.   ...
  4.     procedure Replace(AIndex: Integer; AImage, AMask: TCustomBitmap; const AllResolutions: Boolean = True);
  5.     procedure ReplaceSlice(AIndex: Integer; Image: TCustomBitmap; AImageRect: TRect; const AllResolutions: Boolean = True);
  6.     procedure ReplaceSliceCentered(AIndex, AImageWidth: Integer; Image: TCustomBitmap; const AllResolutions: Boolean = True);
  7.     procedure ReplaceIcon(AIndex: Integer; AIcon: TCustomIcon);
  8.     procedure ReplaceMasked(Index: Integer; NewImage: TCustomBitmap; MaskColor: TColor; const AllResolutions: Boolean = True);
  9.   ...
  10.   end;

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: Replace an image in a TImageList
« Reply #2 on: March 09, 2023, 01:03:43 pm »
Thanks wp, I'll see what I can do with that  ;)
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: Replace an image in a TImageList
« Reply #3 on: March 10, 2023, 01:33:49 pm »
I hadn't realised that those procedures are already part of TImageList, I really should have looked into that more %). Thanks for your post that got me there wp ;)
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: {SOLVED] Replace an image in a TImageList
« Reply #4 on: March 10, 2023, 02:08:44 pm »
When your source code contains the word "TImageList", hold down the Ctrl-Key and click on "TImagelist" -- this opens the unit in which TImageList is defined. TImageList has only published properties, therefore repeat the same procedure with the ancestors TDragImageList (in "TImageList = class(TDragImageList)") and TCustomImageList to get to the declaration of TCustomImageList in which all the methods and properties are listed. Scroll down a bit to see them.

Navigating the source code is the ultimate and most up-to-date help tool.

petevick

  • Sr. Member
  • ****
  • Posts: 337
Re: {SOLVED] Replace an image in a TImageList
« Reply #5 on: March 10, 2023, 04:04:08 pm »
When your source code contains the word "TImageList", hold down the Ctrl-Key and click on "TImagelist" -- this opens the unit in which TImageList is defined. TImageList has only published properties, therefore repeat the same procedure with the ancestors TDragImageList (in "TImageList = class(TDragImageList)") and TCustomImageList to get to the declaration of TCustomImageList in which all the methods and properties are listed. Scroll down a bit to see them.

Navigating the source code is the ultimate and most up-to-date help tool.
Well I'll be damned, every days a learning day  :o I wish I'd known about that a year ago  :D :D Thanks for todays lesson wp  ;D
Pete Vickerstaff
Linux Mint 21.1 Cinnamon, Lazarus 3.2, FPC 3.2.2

dsiders

  • Hero Member
  • *****
  • Posts: 1052
Re: {SOLVED] Replace an image in a TImageList
« Reply #6 on: March 10, 2023, 09:35:45 pm »
I have someting in mind I'd like to do that would require me to replace, in a TImageList, an image at a given ImageIndex with another image at runtime. Would this be possible ?? I've searched online and couldn't find anything definitive.

Since you're on Linux, I am assuming the CHM files are not available.

When you say "online", are you referring to https://lazarus-ccr.sourceforge.io/docs/? That site hasn't been updated since 2018 (1.8.4?).

Maybe this would be of more helpful (pun intended): https://dsiders.gitlab.io/lazdocsnext/lcl/imglist/tcustomimagelist.html. These are docs generated against the "trunk" version... but it has to be more useful than the Source Forge site.

And, as @WP suggests, there is always the source...
Preview Lazarus 3.99 documentation at: https://dsiders.gitlab.io/lazdocsnext

 

TinyPortal © 2005-2018