Recent

Author Topic: TImageList.draw is not drawing disabled images  (Read 490 times)

daniel_sap

  • Jr. Member
  • **
  • Posts: 91
TImageList.draw is not drawing disabled images
« on: March 27, 2025, 12:40:46 pm »
Hi
I used to draw disabled images in Delphi with TImageList.draw
But now I try it in Lazarus LCL and it's not drawing the image disabled.

I created also a speed button to test what will happen with the image when it is disabled and also the speed button is not drawing it disabled.
Do you have an idea what could be the issue

Lazarus 4.0RC1 (rev t-fixes-4-58-g43d904ed50) FPC 3.2.2 x86_64-win64-win32/win64

This is the code where I try the speed button
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Buttons, StdCtrls;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     CheckBox1: TCheckBox;
  16.     ImageList1: TImageList;
  17.     SpeedButton1: TSpeedButton;
  18.     procedure CheckBox1Change(Sender: TObject);
  19.   private
  20.  
  21.   public
  22.  
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.CheckBox1Change(Sender: TObject);
  35. begin
  36.   SpeedButton1.Enabled := CheckBox1.Checked;
  37.   Repaint;
  38. end;
  39.  
  40. end.
  41.  

wp

  • Hero Member
  • *****
  • Posts: 12757
Re: TImageList.draw is not drawing disabled images
« Reply #1 on: March 27, 2025, 01:16:59 pm »
I cannot confirm this - see attached mini-demo.

daniel_sap

  • Jr. Member
  • **
  • Posts: 91
Re: TImageList.draw is not drawing disabled images
« Reply #2 on: March 27, 2025, 01:50:11 pm »
I cannot confirm this - see attached mini-demo.

I tried your project is working as expected on my side

The difference on my side is that images are 16x16

I created a mini demo also and attach it here.
Also attached the original image I test with

wp

  • Hero Member
  • *****
  • Posts: 12757
Re: TImageList.draw is not drawing disabled images
« Reply #3 on: March 27, 2025, 02:24:20 pm »
Your demo is working correctly. The problem is that your image is almost black&white. Therefore, the conversion to grayscale is barely visible. Find a different image (there is a large collection of free icons in the folder images/general_purpose of the Lazarus installation). Or modify it by some pixel editor to look more like you think it should, add it to the image list and specify its index in the DisabledImageIndex property.
« Last Edit: March 27, 2025, 03:16:14 pm by wp »

daniel_sap

  • Jr. Member
  • **
  • Posts: 91
Re: TImageList.draw is not drawing disabled images
« Reply #4 on: March 28, 2025, 07:51:31 am »
Your demo is working correctly. The problem is that your image is almost black&white. Therefore, the conversion to grayscale is barely visible. Find a different image (there is a large collection of free icons in the folder images/general_purpose of the Lazarus installation). Or modify it by some pixel editor to look more like you think it should, add it to the image list and specify its index in the DisabledImageIndex property.

Thank you, wp
I changed few icons and works good.

However, will go in direction for custom mask for drawing the disabled images.
For me black color as any other color can look disabled.

 

TinyPortal © 2005-2018