Recent

Author Topic: Tray Icon from Imagelist, does not change with Getimage  (Read 465 times)

linuxer

  • New Member
  • *
  • Posts: 23
Tray Icon from Imagelist, does not change with Getimage
« on: January 27, 2020, 08:37:31 am »
Hi,

I am facing the following problem.

In my Image list, the icons exist with different resolutions (Image attached)

    ImageList1.Width            := 64;
    ImageList1.Height           := 64;
    ImageList1.Scaled           := true;       
    ImageList1.GetIcon(0, TrayIcon1.Icon); ------> Only no. 0 Indexed Appears, no matter if I choose no. 1 instead
    TrayIcon1.Show;
    .......
    .......
    // later on change
    ImageList1.GetIcon(1, TrayIcon1.Icon);   -----> Icon Does not Change                             ]

The same situation happens, if on my first ImageList.GetIcon() statement, the no. 1 indexed BMP, is selected.

Awaiting your response

Regards

MarkMLl

  • Hero Member
  • *****
  • Posts: 623
Re: Tray Icon from Imagelist, does not change with Getimage
« Reply #1 on: January 27, 2020, 01:31:42 pm »
Has this previously been working, and if so can you say with which version of Lazarus and FPC?

I have very little experience with icons and bitmaps, but it could be related to a similar problem I was discussing a couple of days ago relating to ToolButtons.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

linuxer

  • New Member
  • *
  • Posts: 23
Re: Tray Icon from Imagelist, does not change with Getimage
« Reply #2 on: January 27, 2020, 04:47:23 pm »
It is a new project, so I am not in the position to tell, if it was working before, but it normally should.

FPC version is 3.3.1

Lazarus version 2.1.0

wp

  • Hero Member
  • *****
  • Posts: 6723
Re: Tray Icon from Imagelist, does not change with Getimage
« Reply #3 on: January 27, 2020, 07:16:26 pm »
The attached demo tries to simulate what you describe (if I understand correctly).

Because I normally do not work with icons from image lists I added two images lists, one with png, and one with ico images. They can be selected with the radiogroup. Each image list contains two images at various sizes which can be toggled with the button. The selected image is extracted as icon and assigned to the TrayIcon.

On my system (Win 10, Laz trunk/fpc 3.0.4, and Laz trunk/fpc trunk) the tray icon changes correctly for both png and ico image lists. Thus I cannot reproduce your issue.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

linuxer

  • New Member
  • *
  • Posts: 23
Re: Tray Icon from Imagelist, does not change with Getimage
« Reply #4 on: January 28, 2020, 09:10:02 am »
Thank you very much for your kind assistance!  :) :) :) :) :)

Regards