lazres: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: lazres
| Old | New | Line | |
|---|---|---|---|
| 1 | + | > **Note:** Since Lazarus v1.4.0, Lazarus has switched to .res format instead of .lrs; see [[Lazarus 1.4.0 release notes]].\ | |
| 2 | + | > To create .res resource files you can use either **lazres** or **winres** | |
| 3 | + | ||
| 4 | + | **lazres** is a [[Lazarus Resources|lazarus resource]] tool to create and convert `.rc`, `.lrs` and `.res` files. | |
| 5 | + | ||
| 6 | + | Lazres can be found as `<root>/lazarus/tools/lazres.lpi` and might need to be compiled. In Ubuntu installations `lazres` is precompiled and available in `/usr/bin` | |
| 7 | + | ||
| 8 | + | `Usage: lazres resourcefilename filename1[=resname1] [filename2[=resname2] ... filenameN=resname[N]]`\ | |
| 9 | + | ` lazres resourcefilename @filelist` | |
| 10 | + | ||
| 11 | + | To create a resource file MYRES.RES with two .bmp graphics files use: | |
| 12 | + | ||
| 13 | + | `lazres MYRES.RES MyImage1.bmp=IMG1 MyImage2.bmp=IMG2` | |
| 14 | + | ||
| 15 | + | A resource file can be of type: | |
| 16 | + | ||
| 17 | + | | | | | | | |
| 18 | + | |--------|---------------------------|-----------|---------| | |
| 19 | + | | `.RC` | resource description file | plaintext | | | |
| 20 | + | | `.LRS` | lazarus (pascal) resource | plaintext | | | |
| 21 | + | | `.RES` | compiled resource | binary | default | | |
| 22 | + | ||
| 23 | + | ## Using resources | |
| 24 | + | ||
| 25 | + | ### .lrs | |
| 26 | + | ||
| 27 | + | Include .lrs file in the [[Initialization|initialization]] section | |
| 28 | + | ||
| 29 | + | ``` pascal | |
| 30 | + | initialization | |
| 31 | + | // .LRS files are plain-text pascal statements and need unit LResources to be included in the Uses clause | |
| 32 | + | {$I MyResources.lrs} | |
| 33 | + | end. | |
| 34 | + | ``` | |
| 35 | + | ||
| 36 | + | ### .res | |
| 37 | + | ||
| 38 | + | Load .res file in the [[Implementation|implementation]] section | |
| 39 | + | ||
| 40 | + | ``` pascal | |
| 41 | + | implementation | |
| 42 | + | // .RES files are binary resources and can be loaded | |
| 43 | + | {$R MyResources.res} | |
| 44 | + | ||
| 45 | + | var | |
| 46 | + | img: TImage; | |
| 47 | + | begin | |
| 48 | + | img.Picture.Bitmap.LoadFromResourceName( hInstance, 'IMG1' ); | |
| 49 | + | end; | |
| 50 | + | ``` | |
| 51 | + | ||
| 52 | + | ## See also | |
| 53 | + | ||
| 54 | + | - [[fcl-res|FCL resource units]] | |
| 55 | + | - [[Lazarus Resources|Description of using FPC and Lazarus resources]] | |
| 56 | + | - [[IDE Window: Project Options|IDE Project Options > Resources]] | |
| 57 | + | ||
| 58 | + | --- | |
| 59 | + | *From the Free Pascal wiki, page "lazres", as it stood on 2020-08-13 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
