Recent

Author Topic: Creating component icons  (Read 3258 times)

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Creating component icons
« on: June 26, 2016, 12:55:24 am »
I've created a component (stringgrid descendant) which is now available on myPalette.
I've created a 24 x 24 pixel PNG file for the desired icon.
I've installed & used LRS Explorer 1.0.0.1 and it appears to have correctly created an LRS file. At least when I open the LRS file in the LRS Explorer, I see MyGrid(PNG) in the Resources List, and I see the icon in the Resource Viewer.

In my component file I've placed.
Code: Pascal  [Select][+][-]
  1. procedure Register;
  2. begin
  3.   {$I MyGrid.lrs}
  4.   RegisterComponents('MyPalette', [TMyGrid]);
  5. end;
 

When I compile the package which holds this component, [and of course rebuild Lazarus in the process] the icon shown on my palette is the default one (red, green, and blue boxes) instead of the desired icon.

What have I done wrong?
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Re: Creating component icons
« Reply #1 on: June 26, 2016, 04:26:05 pm »
I discovered that it's easy to link up a 24 x 24 pixel PNG file with a new component so long as you do this when the component is first created. After clicking package -> Add -> New Component there is a clearly marked button to add the desired PNG file. Works great!

Is there some way to add a PNG icon after the component has been created.
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

lainz

  • Hero Member
  • *****
  • Posts: 4473
    • https://lainz.github.io/
Re: Creating component icons
« Reply #2 on: June 26, 2016, 05:32:06 pm »
Open the resource with a text editor and ensure that it has this format:

LazarusResources.Add('TMyPallete','PNG',[
...
The name of the component must be in.

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: Creating component icons
« Reply #3 on: June 26, 2016, 05:33:48 pm »
You are right, icons must be 24x24 pixels. The resource name must match the component name. You can add the icon also to a res resource.

In order to add an icon later you just have to rebuild the ide.

See http://wiki.freepascal.org/Lazarus_Packages for some more information.

 

TinyPortal © 2005-2018