Recent

Author Topic: Component Icon Queries  (Read 180 times)

Rostelle

  • New member
  • *
  • Posts: 5
Component Icon Queries
« on: March 14, 2019, 03:37:06 pm »
I have fairly recently abandoned Delphi in favour of Lazarus
Using IDE v1.6.2 on Windows 10
Today I have been attempting to get components working
I have created two components for testing purposes
TmyPanel and TmyBevel (originality befitting any developer)
I have these installed in a package (myComps) with their own icons on a myComps toolbar
So generally feeling quite pleased
However I am left with two queries

I cannot get a wildcard to work with Lazres while trying to compile my icon .png files into a resource file
I have deliberately placed my icon files in the same folder
So, the following works
C:\lazarus\tools\lazres myCompIcons.res TmyPanel.png TmyBevel.png
but the following does not work
C:\lazarus\tools\lazres myCompIcons.res *.png
it produces a message indicating the file *.png was not found
Query 1) Am I overlooking something obvious or is this just how it works ?
Query 1a) Is there any other method which would allow wildcards to be used ?
The reason for the second part of the query is I eventually expect to build up a reasonable size library of components and to make it much simpler to have a batch file to re-create the resource file after any additions or changes

Having added the resource file to the package I also had to reference it in one of the component .pas files by placing the following resource directive.
{$R myCompIcons.res}
It only needs to be in one of the component .pas files for both components to pick up their icons.
Query 2) Is this really necessary or have I missed another step ?
Query 2a) Is there anywhere else (somehow directly into the package) that I could place the directive ?
The reason for this question is I feel I must have missed a trick, the Package knows about the resource file, only one .pas needs it referenced, just seems odd.
« Last Edit: March 14, 2019, 03:46:04 pm by Rostelle »

wp

  • Hero Member
  • *****
  • Posts: 5452
Re: Component Icon Queries
« Reply #1 on: March 14, 2019, 04:21:07 pm »
I think that wildcards are not evaluated by lazres. But you can use a file list, i.e:
Code: [Select]
dir /b *.png > image_list.txt
lazres mycompicons.res @image_list.txt

I'd recommend to use a single registration unit in which you register all components of your package and which also contains the {$R mycompicons.res}. This facilitates the next step which will eventually come, namely separation of runtime and designtime code by using runtime and designtime packages.

[EDIT]
When you want to see how Lazarus does it, look at the batch files in the folder images of your Lazarus installation.
« Last Edit: March 15, 2019, 11:45:00 am by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Rostelle

  • New member
  • *
  • Posts: 5
Re: Component Icon Queries
« Reply #2 on: March 14, 2019, 05:55:08 pm »
Many thanks wp
I shall give that a try tomorrow (or possibly next week - I am quite easily distracted)