Difference between revisions of "How to add icons my package components"

From Lazarus wiki
Jump to navigationJump to search
(Created page with "We have package "my_pkg" with components TComp1, TComp2 and want to add icons for components to IDE component pallette. First we have to prepare icons in .png files, size 24x...")
 
(Categorization)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
We have package "my_pkg" with components TComp1, TComp2 and want to add icons for components to IDE component pallette.
+
We have package "my_pkg" with components TComp1, TComp2 and want to add icons for components to IDE component pallete.
  
First we have to prepare icons in .png files, size 24x24.
+
First we have to make .png 24x24 files: tcomp1.png, tcomp2.png.
If you want get them from Delphi package, you can use the free "XN Resource Editor" to export icons from .dcr files.
+
If you want to get them from Delphi package, you can use the free "XN Resource Editor" to export icons from .dcr files.
  
 
Now we need app "lazres". It's located in "tools" subfolder of IDE folder.
 
Now we need app "lazres". It's located in "tools" subfolder of IDE folder.
Line 8: Line 8:
 
We use lazres.exe to create Lazarus resource file .lrs from .png files:
 
We use lazres.exe to create Lazarus resource file .lrs from .png files:
  
    c:\lazarus\tools\lazres.exe my_pkg_icons.lrs TComp1.png TComp2.png
+
  c:\lazarus\tools\lazres.exe my_icons.lrs *.png
  
Into package my_pkg we add file my_pkg_icons.lrs (tab "Add file", type LRS).
+
Into package my_pkg we add file my_icons.lrs (tab "Add file", type LRS).
 +
At least one unit in package must have:
  
At least one unit in package must have "initialization" in which we must write
+
* "initialization" in which we must write  
  
    {$I my_pkg_icons.lrs}
+
  {$I my_icons.lrs}
  
After installing package, component pallette must have icons for TComp1, TComp2.
+
* also "uses LResources" in this unit.
 +
 
 +
Compile and install the package, two icons must appear.
 +
 
 +
[[Category:Packages]]

Latest revision as of 19:44, 26 July 2015

We have package "my_pkg" with components TComp1, TComp2 and want to add icons for components to IDE component pallete.

First we have to make .png 24x24 files: tcomp1.png, tcomp2.png. If you want to get them from Delphi package, you can use the free "XN Resource Editor" to export icons from .dcr files.

Now we need app "lazres". It's located in "tools" subfolder of IDE folder. Compile it under Windows: "c:\lazarus\tools\lazres.lpi" to lazres.exe. We use lazres.exe to create Lazarus resource file .lrs from .png files:

 c:\lazarus\tools\lazres.exe my_icons.lrs *.png

Into package my_pkg we add file my_icons.lrs (tab "Add file", type LRS). At least one unit in package must have:

  • "initialization" in which we must write
 {$I my_icons.lrs}
  • also "uses LResources" in this unit.

Compile and install the package, two icons must appear.