Recent

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

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
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

  • Sr. Member
  • ****
  • Posts: 252
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: 949
  • ..... A day not Laughed is a day wasted !!
    • 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 3.99 (rev main_3_99-649-ge13451a5ab) FPC 3.3.1 x86_64-darwin-cocoa
Mac OS X Monterey

fatmonk

  • Sr. Member
  • ****
  • Posts: 252
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

 

TinyPortal © 2005-2018