DATASTEAD Software
Multimedia Components

-Home

 

Products

-TVideoGrabber

-TActiveMovie

-THttpScan
 

Customer area

- login
  

Company

-Contact

-About us
 

Mirror site

- www.datastead.fr

 


DFMToSource v2.1  -  June 6, 2002
description      download      screenshots      user guide      support      order

USER GUIDE

Component's graphical properties

Full DFM

Options

 

 

COMPONENT'S GRAPHICAL PROPERTIES: HOW DOES IT WORK?

- DFMToSource analyzes the components from the clipboard or from the DFM file,

- DFMToSource lists the components having bitmaps or icons, like TImageList, TImage, TSpeedButton, TBitBtn, etc...

- you select the components that you want to convert to source code and generate the source code,

- you paste this source code in your project's source code,

- you call the Load... function to initialize the bitmaps or icons of your component.



COMPONENT'S GRAPHICAL PROPERTIES: DELPHI HOW-TO

- Run  DFMToSource, open the DFM file containing the components. 

You can also open the project, select the components on the form, copy them to the clipboard, swap to DFMToSource and click on "paste components from clipboard" 

- select the components you want to convert to source code,

- right-click on "generate code",

- select the code in the "Delphi" memo, copy it to the clipboard,

- paste the code in your project's source file,

- add "ComCtrls, CommCtrl, ExtCtrls, Buttons" to the uses clause,

- after the component creation statements, then call the Load... procedure to initialize the graphical properties. E.g.:

procedure TForm1.Button1Click(Sender: TObject);
begin
   SpeedButton1 := TSpeedButton.Create (Self);  
   SpeedButton1.Parent := Self;
   LoadSpeedButton1(SpeedButton1);
end;



COMPONENT'S GRAPHICAL PROPERTIES: C++BUILDER HOW-TO

- Run  DFMToSource, open the DFM file containing the components. 

You can also open the project, select the components on the form, copy them to the clipboard, swap to DFMToSource and click on "paste components from clipboard" 

- select the components you want to convert to source code,

- right-click on "generate code",

- select the code in the "Delphi" or "C++Builder" memo, copy it to the clipboard,

- paste the code in your project's source file,

- add a "#define NO_WIN32_LEAN_AND_MEAN" directive at the top of the source file,

- after the component creation statements, then call the Load... procedure to initialize the graphical properties. E.g.:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
TSpeedButton *SpeedButton1;

SpeedButton1 = new TSpeedButton (this);
SpeedButton1->Parent = this;
LoadSpeedButton1 (SpeedButton1);
}


COMPONENT'S GRAPHICAL PROPERTIES RESTRICTIONS

The following classes (and their derived classes) are supported:

TImageList
TImage
TSpeedButton
TBitBtn
TPicture
TBrush
TCoolBar
TCoolBand
TControlBar

The following classes (and their derived classes) are NOT supported:

TTreeView
TListView 


FULL DFM: HOW DOES IT WORK?

DFMToSource reads your form's DFM file (e.g. demo.dfm), and generates an independent source file within your project directory as .pas or .cpp file (e.g. demodfm.pas or demodfm.cpp) according to Delphi, C++Builder or both. 

You simply invoke it from your project by an "include" statement as explained below. Only 2 or 3 lines of your project's code has to be changed to switch between the "with DFM" compilation and the "without DFM" compilation.

The "Full DFM" feature includes an optional watchdog that keeps the source code up-to-date according the last DFM file version.

DFMToSource works with main application forms as well as standard forms.


Full DFM for DELPHI HOW-TO

First of all, for the  samples below  let's say we are talking about the Unit2.pas and Unit2.dfm files that describe the Form2: TForm2 form.

1. generate the DFM form's source code:

- run DFMToSource,

- click "Options" | "Delphi or C++Builder..." and select "Delphi (.pas)"

- click on "File" | "Open Form file...", select your project's form file (Unit2.dfm),

- the source code has been generated within your project's directory as Unit2dfm.pas.



2. add 3 lines of code to your form's unit:

- run Delphi, open your project, open Unit2.pas,

- in the "public" section of the TForm2 class declaration, add the following statement:
constructor BuildForm (AOwner: TComponent);

- comment the {$R *.DFM} directive:
//{$ *.DFM}

- in the "implementation" section, add the following 2 lines:
constructor TForm2.BuildForm (AOwner: TComponent);
{$include Unit2dfm.pas}

Click here to see a sample screenshot of these changes.



3a. IF THE FORM IS CREATED AUTOMATICALLY BY THE PROJECT'S PAS FILE: add 1 line of code to your project ".pas" file:

- click on "Project | View Source"

- add the following statement before the "Application.CreateForm (TForm2, Form2)" statement corresponding to the concerned form:
Form2 := TForm2.BuildForm (Application);

- comment the "Application.CreateForm (TForm2, Form2)" statement.
//Application.CreateForm (TForm2, Form2);

Click here to see a sample screenshot of these changes.



3b. IF YOU CREATE THE FORM PROGRAMMATICALLY: invoke the form creation as following:

procedure TForm1.Button1Click(Sender: TObject);
begin
   Form2 := TForm2.BuildForm (Application);
   Form2.Visible := true;
end;

Click here to see a sample screenshot of these changes.



4. run your project:

The form is now dynamically created using the source code instead of the DFM or XFM form's file.

 

5. to switch back to the "DFM file" mode:

- comment the Form2 := TForm2.BuildForm (Application) statement,

- uncomment the "Application.CreateForm (TForm2, Form2)" statement,

- uncomment the {$R *.DFM} directive in the form's unit.



FULL DFM for C++BUILDER HOW-TO

1. generate the DFM source code:

- run DFMToSource,

- click "Options" | "Delphi or C++Builder..." and select "C++Builder (.cpp)"

- click on "File" | "Open Form file...", select your project's DFM or XFM file (Unit2.dfm),

- the source code has been generated within your project's directory as Unit2dfm.cpp.



2. add 1 lines of code to the form's header file:

- run C++Builder, open your project,

- open the form's header file (Unit2.h):

- in the "public" section of your form class declaration, add the following statement:
__fastcall TForm2(TComponent* Owner, void *BuildForm);

Click here to see a sample screenshot of these changes.



2. add 3 lines of code to the form's cpp file:

- open the form's CPP file (Unit2.cpp),

- comment the "pragma resource *.dfm" directive:
//#pragma resource "*.dfm"

- add the following lines of code:
__fastcall TForm2::TForm2(TComponent* Owner, void *BuildForm)
: TForm(Owner, 1)
{
#include "Unit2dfm.cpp"
}
Note: TAKE CARE TO "TForm(Owner, 1)". If the "1" is omitted, it will not work.

Click here to see a sample screenshot of these changes.



3a. IF THE FORM IS CREATED AUTOMATICALLY BY THE PROJECT'S CPP FILE: add 2 lines of code to your project ".cpp" file:

- click on "Project | View Source"

- add an include directive to your form's header file:
#include "Unit2.h"

- add the following statement before the "Application->CreateForm(__classid(TForm2), &Form2);" statement corresponding to the concerned form:
Form2 = new TForm2 (Application, NULL);

- comment the "Application->CreateForm(__classid(TForm2), &Form2);" statement:
//Application->CreateForm(__classid(TForm2), &Form2);

Click here to see a sample screenshot of these changes.



3b. IF YOU CREATE THE FORM PROGRAMMATICALLY FROM ANOTHER UNIT:

- add "include "Unit2.h",

- add "include "Unit2.cpp",

-  invoke the form creation as following:

procedure TForm2.Button1Click(Sender: TObject);
begin
   Form2 := TForm2.BuildForm (Application);
   Form2.Visible := true;
end;

Click here to see a sample screenshot of these changes.



4. run your project:

The form is now dynamically created using the source code instead of the DFM file.

 

5. to switch back to the "DFM file" mode:

- comment the  "Form2 := TForm2.BuildForm (Application);" statement (if 3a above)

- uncomment the "Application->CreateForm(__classid(TForm2), &Form2);" statement, (if 3a above)

- uncomment the #pragma resource "*.dfm" directive in the Unit2.h file.

 

 

FULL DFM COMMAND LINE

DFMToSource can be called from the command line. In this case the .pas and/or .cpp files are created and DFMToSource exits immediately. The syntax is the following:

DFMToSource   [path to the DFMfile]    [D, C or B]

with 
D = "Delphi" -> generates a .pas file
C = "C++Builder -> generates a .cpp file
B  = "Both" -> generates both .pas and .cpp files.

E.g.:
DFMToSource  C:\MyProject\Unit1.dfm  D
will create a Unit1dfm.pas file in the C:\MyProject directory. 



OPTIONS

"Delphi or C++Builder..."

  • None (display only) does not create files. The code can be copied to the clipboard.
  • Delphi (.pas) generates a .pas file when the form file is opened
  • C++Builder (.cpp) generates a .cpp file when the form file is opened
  • Both (.pas + .cpp) generates both .pas and .cpp files when the form file is opened

source code width (in columns)

is the maximal width of the source code in columns, especially for the const binary data.

DFM update watchdog

if enabled, DFMToSource checks 1 time per second the age of the opened DFM file. If the DFM file is updated, DFMToSource automatically update the corresponding .pas and/or .cpp files.

Reopen last DFM at startup

if enabled, the last opened Form file is reopened when DFMToSource starts.

Minimize at startup

if enabled, DFMToSource starts minimized.




 

 

License Agreement
 
Copyright ©  2002-2007 Datastead Sarl.  All rights reserved.
Delphi™ and C++Builder™ are trademarks of Borland Corporation. DirectX™ is a trademark of Microsoft Corporation. 
All other trademarks are the sole property of their respective owners.