Recent

Author Topic: Assigning an icon from a resource  (Read 179 times)

fatmonk

  • Full Member
  • ***
  • Posts: 222
Assigning an icon from a resource
« on: December 03, 2019, 11:58:20 am »
I believe I've added a second icon to my project for use in a file association by adding an icon type resource under Resources in the Project Options dialog.

I want to assign this icon as a FileAssociation.ExtensionIcon but cannot figure out how to assign it.

I can include the second icon as a separate file alongside the exe, but I was hoping that by including it as a resource I could avoid that and just distribute the exe on its own but still have two (or more) different icons available.

FileAssociation.ExtensionIcon is looking for a string so referencing the resource might not be possible...

-FM


fatmonk

  • Full Member
  • ***
  • Posts: 222
Re: Assigning an icon from a resource
« Reply #1 on: December 03, 2019, 12:16:53 pm »
OK, I think I might have figured this out...

When you add the multiple icons as resources, it looks like you can access them as follows:

Code: [Select]
FileAssociation_type1.ExtensionIcon:=Application.ExeName+',0';
FileAssociation_type1.ExtensionIcon:=Application.ExeName+',1';

At least it seems to be working...

-FM

madref

  • Hero Member
  • *****
  • Posts: 700
  • ..... A day not Laughed is a day not Lived !!
    • Nursing With Humour
Re: Assigning an icon from a resource
« Reply #2 on: December 04, 2019, 12:09:01 pm »
Is this only under windows?
Or does this also work with MacOS?
You treat a disease, you win, you lose.
You treat a person and I guarantee you, you win, no matter the outcome.

Lazarus 2.0.2 / FPC 3.0.4
Lazarus Trunc / FPC 3.0.4
Mac OS X Mojave

fatmonk

  • Full Member
  • ***
  • Posts: 222
Re: Assigning an icon from a resource
« Reply #3 on: December 04, 2019, 12:31:39 pm »
I'm only working under Windows and don't have a Mac to try on.

I don't have Windows in my uses declaration, though, so I don;t believe I'm using anything Windows specific in my code.

-FM