Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Forms and Frames declared in .dpr

24 views
Skip to first unread message

ElGecko

unread,
Jan 27, 2009, 8:22:06 AM1/27/09
to
Hi everyone,

I am looking for some clues about the interaction of the IDE with dfm
files and a project's dpr.

Here's my case :
We have here a utility to "refresh" the .dpr file of a project - a
simple tool which recursively scans the USE clauses of all units in a
project, and creates a fresh dpr file which declares the units in a
convenient order.

Our utility produces .dpr files which allow us to compile our projects
just fine, and the resulting executable behaves as expected.
Our utility does not handle correctly the forms and frames declared in
adjacent .dfm files, though. And this causes problems, for instance
when using a Frame declared in another unit - the IDE complains that
it can't find the corresponding component.

So I started looking into how it was handled by the IDE.

I figured the following rules :
-a Form is declared in the .dpr as a comment, next to the unit
declaration;
e.g. : the line " Form1 in "src\Form1.pas" {Form1}," in the dpr
declares both that the unit Form1.pas is part of the project, and that
a component, named Form1, is declared in the file Form1.dfm.
The class Form1 is supposedly a TForm, and the IDE treats it as such
(ie: it proposes Form1 as a derivable class in the tools panel...) ; I
tried to mess with the dpr, and falsely declare a Frame component with
the syntax for a Form, the IDE does not seem to complain, but treats
it as a Form (more precisely : it accepts to edit any dfm's containing
the frame component, it just won't offer the frame component in the
"Frame" list of the tool panel, and the resulting executable does not
seem to notice either);

-a Frame is declared in de .dpr as a comment, in the form
"{FrameClassName: TFrame}
e.g. : the line " Frame2 in "src\Frame2.pas" {Frame2: TFrame},"
in the dpr declares both that the unit Frame2.pas is part of the
project, and that a component, named Frame2, is declared in the file
Frame2.dfm.
This class is supposed to derive from TFrame - I tried to declare a
form component as a Frame ( "{Form1: TFrame}" ), the IDE messed up.
When I say "declaration", I mean that the IDE needs those comments to
recognize and register correctly all the frames and forms as
components. The compiler doesn't care, nor does the produced
executable.

My (three) questions :
1 - Are my asumptions correct? have I missed any rules regarding the
declaring part?

2 - If I scan through my projects' directories, when scanning a dfm
file, do I just have to parse the first line of the dfm (which reads
"object Form1 : TForm1", or "inherited Form2 : TForm2") to find the
component which is declared? are there som other patterns?

3 - If I revuild completely my .dpr, and loose the information
initially written by the IDE, how can I distinguish between a Frame
and a Form? Do I have to parse the whole classes hirerachy in the .pas
files to find out wether the root class is TForm or TFrame? are there
some other means?

Thanks in advance,
*G.*

ElGecko

unread,
Jan 27, 2009, 8:23:20 AM1/27/09
to
I forgot to precise : we are working under BDS2006.
0 new messages