lazres: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | > **Note:** Since Lazarus v1.4.0, Lazarus has switched to .res format instead of .lrs; see [[Lazarus 1.4.0 release notes]].\ | |
| 2 | 2 | > To create .res resource files you can use either **lazres** or **winres** | |
| 3 | 3 | ||
| 4 | 4 | **lazres** is a [[Lazarus Resources|lazarus resource]] tool to create and convert `.rc`, `.lrs` and `.res` files. | |
| 5 | 5 | ||
| 6 | 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 | 7 | ||
| 8 | - | ||
| 9 | - | ||
| 8 | + | ```text | |
| 9 | + | Usage: lazres resourcefilename filename1[=resname1] [filename2[=resname2] ... filenameN=resname[N]] | |
| 10 | + | lazres resourcefilename @filelist | |
| 11 | + | ``` | |
| 10 | 12 | ||
| 11 | 13 | To create a resource file MYRES.RES with two .bmp graphics files use: | |
| 12 | 14 | ||
| 13 | - | ||
| 15 | + | ```text | |
| 16 | + | lazres MYRES.RES MyImage1.bmp=IMG1 MyImage2.bmp=IMG2 | |
| 17 | + | ``` | |
| 14 | 18 | ||
| 15 | 19 | A resource file can be of type: | |
| 16 | 20 | ||
| 17 | 21 | | | | | | | |
| 18 | 22 | |--------|---------------------------|-----------|---------| | |
| 19 | 23 | | `.RC` | resource description file | plaintext | | | |
| 20 | 24 | | `.LRS` | lazarus (pascal) resource | plaintext | | | |
| 21 | 25 | | `.RES` | compiled resource | binary | default | | |
| 22 | 26 | ||
| 23 | 27 | ## Using resources | |
| 24 | 28 | ||
| 25 | 29 | ### .lrs | |
| 26 | 30 | ||
| 27 | 31 | Include .lrs file in the [[Initialization|initialization]] section | |
| 28 | 32 | ||
| 29 | 33 | ``` pascal | |
| 30 | 34 | initialization | |
| 31 | 35 | // .LRS files are plain-text pascal statements and need unit LResources to be included in the Uses clause | |
| 32 | 36 | {$I MyResources.lrs} | |
| 33 | 37 | end. | |
| 34 | 38 | ``` | |
| 35 | 39 | ||
| 36 | 40 | ### .res | |
| 37 | 41 | ||
| 38 | 42 | Load .res file in the [[Implementation|implementation]] section | |
| 39 | 43 | ||
| 40 | 44 | ``` pascal | |
| 41 | 45 | implementation | |
| 42 | 46 | // .RES files are binary resources and can be loaded | |
| 43 | 47 | {$R MyResources.res} | |
| 44 | 48 | ||
| 45 | 49 | var | |
| 46 | 50 | img: TImage; | |
| 47 | 51 | begin | |
| 48 | 52 | img.Picture.Bitmap.LoadFromResourceName( hInstance, 'IMG1' ); | |
| 49 | 53 | end; | |
| 50 | 54 | ``` | |
| 51 | 55 | ||
| 52 | 56 | ## See also | |
| 53 | 57 | ||
| 54 | 58 | - [[fcl-res|FCL resource units]] | |
| 55 | 59 | - [[Lazarus Resources|Description of using FPC and Lazarus resources]] | |
| 56 | 60 | - [[IDE Window: Project Options|IDE Project Options > Resources]] | |
| 57 | 61 | ||
| 58 | 62 | --- | |
| 59 | 63 | *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).* |
