delphi

What does the phrase {$R *.dfm} mean in the code editor?


What does the phrase {$R *.dfm} mean in the code editor?

I have tried this:

//{$R *.dfm}

Solution

  • You'll want to keep that in there. The $R directive links a resource file into the EXE. The *.dfm means "the file that has the same filename as this .pas file, but with a .dfm extension instead."

    What it does is makes sure that when the compiler builds the project, that your form data ends up compiled in. Without this, when your code tries to load up the form, it won't be able to find the form data and it will crash.