DelphiBasics
$Resource
Compiler Directive
Defines a resource file to be included in the application linking
1   {$Resource FileName}
2   {$Resource 'FileName.res' 'FileName.rc'}
Description
The $Resource compiler directive defines a resource file to be included in the final linking of a unit.
 
Version 1
 
This is commonly used to include a form file for a GUI application unit. For example, Unit1.pas will have a form definition source file Unit1.dfm. This is loaded using {$Resource *.dfm}. The * is not a wild card - it is always replaced by the current .pas file name.
 
Version 2
 
This is a more specialised version, used in project (*.dpr) files. It tells Delphi to compile the FileName.rc file into the FileName.res file. Only .res files can be linked into the application.
Notes
$Resource is equivalent to $R.

This directive can be used multiple times within your code.
Related commands
$R Determines whether Delphi checks array bounds
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : Include a form dfm file in an application
unit Unit1;
// Note - the form must have the OnCreate event set to
//        the FormCreate procedure below.

interface

uses
  Controls, Forms, Dialogs, Classes, StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  // Simply say hello!
  ShowMessage('Hello World');
end;

end.
   Hello World
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page