0

I've read THIS but it's for Delphi 7 and it's not working in 2009. There are a lot of changes between this two versions. In D7 icons are 24x24, in D2009 icons are 16x16... and in D2009 there is no Image Editor for resorces...

I have a unit SuperList.pas with TSuperList class inside and a separete TSuperList.ico (16x16 16 colors) that I want to use it as the tool palette icon for my component.

This is what I tried...

  • I start Delphi,
  • File->New->Pakage,
  • Add.. SuperList.pas,
  • Project->Resources...->Add.. TSuperList.ico,
  • I changed Resource Identifier to TSUPERLIST (two times! it seems it has a bug),
  • Install the pakage,
  • restart Delphi.

And the icon is still the default one !

Community
  • 1
  • 1
Marus Gradinaru
  • 2,824
  • 1
  • 26
  • 55
  • Nothing has changed since Delphi 7 and probably not since Delphi 1. Add your glyph to the .dcr file. Give it the same name as your component. Link the .dcr file to the package. – David Heffernan Nov 06 '14 at 17:47
  • But how can I create a .dcr file if Delphi2009 has no Image Editor ? – Marus Gradinaru Nov 06 '14 at 18:13
  • Simplest is to use the old image editor. Alternatively see this http://stackoverflow.com/questions/6999939/best-way-to-make-a-component-icon-in-delphi-xe-using-only-the-built-in-tools – David Heffernan Nov 06 '14 at 18:19
  • Fundamentally though all you need is to include a bitmap resource with the right name. Any how you like. Your mistake is to use an icon rather than a bitmap. – David Heffernan Nov 06 '14 at 18:25
  • There is a problem. My icon use the whole 16x16 pixel space and the color of the bottom-left pixel of the bitmap is considered as the transparency color. – Marus Gradinaru Nov 06 '14 at 18:43
  • You need a 24px bitmap don't you? Or does the ide expect 16px. Either way, you can provide what it expects. Bottom left pixel in transparent color. – David Heffernan Nov 06 '14 at 18:44
  • No, I need a 16px bitmap because that is the size of all palette icons in Delphi 2009. And I tried and it works, but I can't use the bottom-left pixel... and I need it too. – Marus Gradinaru Nov 06 '14 at 18:49
  • Well, you have to fit in with the IDE. Bottom left is transparent. I'm sure you'll be able to handle that. – David Heffernan Nov 06 '14 at 18:51

1 Answers1

1

Nothing much has changed since Delphi 7. You need to link a bitmap resource whose name is the same as the component. You can use many different tools to make bitmaps and compile resources. Your mistake here is that you've linked an icon rather than a bitmap.

This question has useful details and could possibly be considered a duplicate: Best way to make a component icon in Delphi XE using only the built in tools

Community
  • 1
  • 1
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • @bummi I closed as a dupe of a different Q and then reopened. I don't think I can use my dupehammer twice. If somebody else can use theirs, that's fine by me. – David Heffernan Nov 06 '14 at 22:07
  • 1
    Note that the bitmap resource whose name is *exactly* the same as the component's class name (in all caps, btw) must be 24x24 in size. To provide a 16x16 image, use a separate image resource whose name is `16`. To provide a 32x32 image, use a separate image resource whose name is `32`. The three images can be in a single .DCR file. – Remy Lebeau Nov 07 '14 at 18:59