Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Lazarus Pascal - How to load the application icon into a TImage from resources
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 13 years ago
Posts: 3035
Topic starter
January 9, 2026 6:40 AM
To build an About box, I wanted to grab the application cion as I had set it in project options, just so I could make this universal and without the need of extra files.
Took me a minute to figure this out, so I'm posting it here in hopes it will save someone a headache 😉
Preconditions:
Make sure you have assigned an icon to your application, in Project Options!
As a target I used a regular Timage, and the unit I'm working in does not need to be the main unit.
Code:
Image1.Picture.LoadFromResourceName(HINSTANCE, 'MAINICON'); // Grab icon from Application
This will load the main icon into "Image1".
Note: under macOS this may crash, works fine under Windows, Linux not yet tested.
This topic was modified 13 hours ago by
Hans