Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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

  • zibadianzibadian Posts: 6,349Member
    : 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.
Sign In or Register to comment.