What does the directive {$R *.DFM} mean?

In the Delphi program, we can see {$R *.DFM} in the implementation section. I check some example source code comment and it told that {this directive links unit's form file}

I know that it is related to the *.dfm file in project. However, I don't have more understanding than that.

I'm curious on the following questions for now:
Why this directive should be in the implementation section?
In the implementation section, shall we define the routines under this directive or before this directive?

Can you tell me something about that? Any related things are appreciated.

Thank you!

Comments

  • : In the Delphi program, we can see {$R *.DFM} in the implementation section. I check some example source code comment and it told that {this directive links unit's form file}
    :
    : I know that it is related to the *.dfm file in project. However, I don't have more understanding than that.
    :
    : I'm curious on the following questions for now:
    : Why this directive should be in the implementation section?
    : In the implementation section, shall we define the routines under this directive or before this directive?
    :
    : Can you tell me something about that? Any related things are appreciated.
    :
    : Thank you!
    :
    The $R directive links a resource file to the program. It can occur anywhere within the source code, but is normally found right after the implementation. This is easier for other programmers to check if a form definition has an dfm file or not. I think it can also be placed in the interface, but that won't make any sense, because the dfm file is only used by that unit and cannot be used by any other unit.
    The compiler takes the dfm file and creates a windows resource file (.res) from it. This is then linked into the program like any other resource file. This resource file shows the location of the controls (and which controls) and also their captions, and other published properties.

    I hope this clears things up a little.
  • Thank you!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories