[Solved] TrayIcon.Icon: load icon from lazarus resources lazarus / 31-LCL ---------------------------------------------------------------------- jex · 2020-04-19 00:19 Hi, I'm trying to load icon of TrayIcon from resouces, added the .ico files from Project Options -> Resources and compiled project. When trying to change it with code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Form1.TrayIcon1.Icon.LoadFromLazarusResource('myico');it returns an exception with "Resource myico not found". I tried with and without .ico extension. File types in Resources is also ICON. Tried changing names from resources and nothing. How to do that? ... and just in case it matters, I want it to be crossplatform. Thank you ---------------------------------------------------------------------- jamie · 2020-04-19 10:43 I don't know where you got that method call from because I don't see it in the help file? Unless I am blind of course and that could be a possibility !   Anyways, just use the standard resource method... LoadfromresourceID / name etc..  the other targets should work fine that way. ---------------------------------------------------------------------- jex · 2020-04-19 12:14 Thanks. That seems to work with LoadFromResourceName. And btw, LoadFromLazarusResource is in the autocomplete box in the IDE. It compiles but I wonder why it doesn't work... ---------- To future readers; I got it working by using Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Form1.TrayIcon1.Icon.LoadFromResourceName(Hinstance,'yourico');// Note that icon name is the Resource name for that icon from Project Options > Resources.// To set Form icon also same method: Form1.Icon .... ---------------------------------------------------------------------- jamie · 2020-04-19 12:42 If you look in your settings you'll see that those types of resources aren't used but you could use them its only a setting, which is most likely why it didn't work... ---------------------------------------------------------------------- kveroneau · 2020-04-28 22:49 I had a similar issue, but instead of using the TrayIcon, I am trying to populate a TImageList using: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TImageList.AddLazarusResource Not sure why these methods are public if they aren't supposed to be used, I ended up using the following method and it worked: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TImageList.AddResourceName Worked like a charm. Yes, I know you can add images via the GUI to a TImageList, but since I plan on using the same set of icons in multiple windows, I didn't want to add all the icons to many different TImageLists, as that would lead to duplication within the binary file and while the program is running.