Difference between revisions of "lazres"

From Free Pascal wiki
m (See also: Remove entry for this page :-)
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Warning|The current development (trunk) version of Lazarus has switched to .res format instead of .lrs; see [[Lazarus_1.4.0_release_notes]] }}
+
{{lazres}}
 +
{{Note|Since Lazarus v1.4.0, Lazarus has switched to .res format instead of .lrs; see [[Lazarus_1.4.0_release_notes]]. <br /> To create .res resource files you can use either '''lazres''' or '''winres'''}}
  
'''lazres''' is a lazarus resource tool to create and convert <tt>.rc</tt>, <tt>.lrs</tt> and <tt>.res</tt> files.
+
'''lazres''' is a [[Lazarus Resources|lazarus resource]] tool to create and convert <tt>.rc</tt>, <tt>.lrs</tt> and <tt>.res</tt> files.
  
Lazres can be found as <tt><root>/lazarus/tools/lazres.lpi</tt> and needs to be compiled.
+
Lazres can be found as <tt><root>/lazarus/tools/lazres.lpi</tt> and might need to be compiled. In Ubuntu installations <tt>lazres</tt> is precompiled and available in <tt>/usr/bin</tt>
  
 
  Usage: lazres resourcefilename filename1[=resname1] [filename2[=resname2] ... filenameN=resname[N]]
 
  Usage: lazres resourcefilename filename1[=resname1] [filename2[=resname2] ... filenameN=resname[N]]
 
         lazres resourcefilename @filelist
 
         lazres resourcefilename @filelist
  
To create a resource file MYRES.RES with two .png graphics files use:
+
To create a resource file MYRES.RES with two .bmp graphics files use:
  lazres MYRES.RES MyPng1.png=TIMG1 MyPng2.png=TIMG1
+
  lazres MYRES.RES MyImage1.bmp=IMG1 MyImage2.bmp=IMG2
  
 
A resource file can be of type:
 
A resource file can be of type:
Line 16: Line 17:
 
|<tt>.RC</tt> || resource description file || plaintext ||
 
|<tt>.RC</tt> || resource description file || plaintext ||
 
|-
 
|-
|<tt>.LRS</tt> || lazarus (pascal) resource  ||  plaintext || default
+
|<tt>.LRS</tt> || lazarus (pascal) resource  ||  plaintext ||
 
|-
 
|-
|<tt>.RES</tt> || compiled resource || binary ||
+
|<tt>.RES</tt> || compiled resource || binary || default
 
|}
 
|}
 
  
 
==Using resources ==
 
==Using resources ==
  
 
=== .lrs ===
 
=== .lrs ===
Include .res file in the initialization section
 
  
<syntaxhighlight>
+
Include .lrs file in the [[Initialization|initialization]] section
 +
 
 +
<syntaxhighlight lang=pascal>
 
initialization
 
initialization
   // .LRS files are plain-text pascal statements and need unit LResources to be included
+
   // .LRS files are plain-text pascal statements and need unit LResources to be included in the Uses clause
 
  {$I MyResources.lrs}
 
  {$I MyResources.lrs}
 
end.
 
end.
Line 35: Line 36:
  
 
=== .res ===
 
=== .res ===
Load .res file in the implementation section
+
Load .res file in the [[Implementation|implementation]] section
 
   
 
   
<syntaxhighlight>
+
<syntaxhighlight lang=pascal>
 
implementation
 
implementation
 
   // .RES files are binary resources and can be loaded
 
   // .RES files are binary resources and can be loaded
{$R MyResources.res}
+
  {$R MyResources.res}
 +
 
 +
var
 +
  img: TImage;
 +
begin
 +
  img.Picture.Bitmap.LoadFromResourceName( hInstance, 'IMG1' );
 +
end;
 +
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  
[[Category:Tools]]
+
== See also ==
 +
 
 +
* [[fcl-res|FCL resource units]]
 +
* [[Lazarus_Resources|Description of using FPC and Lazarus resources]]
 +
* [[IDE_Window:_Project_Options#Resources|IDE Project Options > Resources]]

Latest revision as of 03:59, 13 August 2020

Deutsch (de) English (en)

Note-icon.png

Note: Since Lazarus v1.4.0, Lazarus has switched to .res format instead of .lrs; see Lazarus_1.4.0_release_notes.
To create .res resource files you can use either lazres or winres

lazres is a lazarus resource tool to create and convert .rc, .lrs and .res files.

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

Usage: lazres resourcefilename filename1[=resname1] [filename2[=resname2] ... filenameN=resname[N]]
       lazres resourcefilename @filelist

To create a resource file MYRES.RES with two .bmp graphics files use:

lazres MYRES.RES MyImage1.bmp=IMG1 MyImage2.bmp=IMG2

A resource file can be of type:

.RC resource description file plaintext
.LRS lazarus (pascal) resource plaintext
.RES compiled resource binary default

Using resources

.lrs

Include .lrs file in the initialization section

initialization
  // .LRS files are plain-text pascal statements and need unit LResources to be included in the Uses clause
 {$I MyResources.lrs}
end.

.res

Load .res file in the implementation section

implementation
  // .RES files are binary resources and can be loaded
  {$R MyResources.res}

var 
  img: TImage; 
begin
  img.Picture.Bitmap.LoadFromResourceName( hInstance, 'IMG1' );
end;

See also