Copyright: Copyright © 1997 RealSoft Development


Aspect Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property Aspect:boolean

Description

The Aspect property, when set to true, will maintain a height to width ratio of the RFM no matter what size it is drawn.


Assign Method

Unit

RFM

Applies to

TRFM

Declaration

procedure Assign(Source:TRFM);

Description

The Assign method will assign one RFM to another, erasing any RFM already there.


AutoFields property

Unit

Rfm

Applies to

TRFMImage

Declaration

property AutoFields: boolean

Description

The Autofields property, when set to true, will cause the TRFMImage to draw field labels when printing.  Field labels are placed in the RFM and named using Realforms.  Data is placed in the fields using the OnPrintField event.


AutoFill Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property AutoFill: boolean

Description

The Autofill property, when set to true, will cause the TRFMImage to draw text labels when printing.  Labels are TLabel components dropped on top of the RFMImage at design time.  The types of Label components recognized can be modified using the FillList property.


AutoLogo Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property AutoLogo: boolean

Description

The Autologo property, when set to true, will cause the TRFMImage to draw image logos when printing.  Logos are Image components dropped on top of the RFMImage at design time.  The types of Image components recognized can be modified using the LogoList property.


AutoSize Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property AutoSize: boolean

Description

The Autosize property, when set to true, will expand or contract the RFMImage component depending on the size of the RFM page.


Canvas Property for RFM
Canvas Property

Unit

Rfm

Applies to

TRFM

Declaration

property Canvas: TCanvas

Description

Runtime and read-only.  Provides access to the internal drawing canvas.


Canvas Property for RFMImage
Canvas Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property Canvas: TCanvas

Description

Runtime and read-only.  Provides access to the internal drawing canvas.


Center Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property Center: boolean

Description

The Center property, when set to true, will center the RFM within the frame of the RFMImage.


Clear Method

Unit

Rfm

Applies to

TRFMImage

Declaration

procedure Clear;

Description

The clear method will erase and RFM data and clear the internal canvas.


ClearBMP Method

Unit

Rfm

Applies to

TRFMImage

Declaration

procedure Clear;

Description

The clear method will clear the internal canvas, leaving the RFM data intact.


Contents
RFM and RFMImage Help

For Delphi 16/32

The TRFM and TRFMImage components support loading, saving, and displaying of Realform Form Files.  TRFM is an abstract image class that contains access methods to the RFM file data.  The TRFMImage provides a visual component wrapper to the TRFM similar to a TImage and TPicture.  In addition the RFMImage component handles form filling, printing, and drawing all in one component.

By reading and displaying an RFM file directly, memory is saved, disk space is saved, and you do not have do deal with metafile inconsistencies.  The RFMImage knows how to draw itself in Delphi 16 and 32 exactly the same.  RFM images also provide superior scaling and printing capabilities.

TRFM Reference

TRFMImage Reference

RFM Data Format

Product Registration

About RealForms


Designing Property

Unit

Rfm

Applies to

TRFM

Declaration

property Designing:boolean

Description

The Designing property, when set to true, causes field labels to be drawn on the RFM using their name as a text representation.


Draw Method

Unit

Rfm

Applies to

TRFM

Declaration

procedure Draw;

Description

The Draw method will draw an RFM to its internal full-size canvas.


DrawTo Method

Unit

Rfm

Applies to

TRFM

Declaration

procedure DrawTo(MyCanvas:TCanvas; MyRect: TRect);

Description

The DrawTo method will draw an RFM to a canvas, stretching it to fit into a rectangle.  Specify a full size rectangle to avoid stretching such as Rect(0, 0, RFM.Width, RFM.Height);


Empty Property

Unit

Rfm

Applies to

TRFM

Declaration

property Empty: boolean

Description

Runtime and read-only.  Returns true if no RFM has been loaded, or an RFM contains zero objects.


Example:  Easy Form Filling

This example uses a  form with an RFMImage, and any RFM loaded into its RFM property.  A button should be dropped anywhere on the form.  Next, drop TLabels down on the RFMImage.  If you want to go the extra mile, drop TDBLabels down, and connect them to a database!  Now drop one or more smaller TImage components on the RFMImage as logos.

Set the AutoFill and AutoLogo properties to true.

The button OnClick event should contain:

procedure TForm1.Button1Click(Sender: TObject);

begin

  RFMImage1.Print;

end;

That's all there is to it.  You could add a printer setup dialog to show before printing.


Example: Print Preview

This example uses two forms in a project.  The first form should contain an RFMImage with Align: alClient set, and any RFM loaded into its RFM property.  A button should be dropped anywhere on the form.  The second form should contain a standard TImage component, preferably aligned to client as well.

Dont to forget to add " uses unit2; " to the first unit.

On the first form, the buttons onclick event should contain:

procedure TForm1.Button1Click(Sender: TObject);

begin

  Form2.Image1.Picture.Bitmap.Width:= Form2.Image1.Width;

  Form2.Image1.Picture.Bitmap.Height:= Form2.Image1.Height;

  RFMImage1.PrintTo(Form2.Image1.Picture.Bitmap.Canvas, RFMImage1.RFMRect);

  Form2.Showmodal;

end;

This will effectively re-draw the RFMImage on the second form's TImage.  You can also drop text labels on the RFMImage, set the AutoFill property to true, and test out simple form filling as well.


Example:  RFM Field Labels

This example uses a  form with an RFMImage, and an RFM loaded into its RFM property.  The RFM should contain "Fields" dropped down in RealForms.  Name three of the Fields: NAME, LOCATION, and PHONE.  The Format of the PHONE field should be set to Phone.  A button should be dropped anywhere on the form.  Set the RFMImage AutoFields property to true.

The button OnClick event should contain:

procedure TForm1.Button1Click(Sender: TObject);

begin

  RFMImage1.Print;

end;

The RFMImage OnPrintField event should contain:

procedure TForm1.RFMIMage1PrintField(Sender: TObject; FieldName: string;

Format: TTextFormat; var Text: string);

begin

  {place text to be printed}

  if FieldName = 'NAME' then Text:= 'RealSoft Development';

  if FieldName = 'LOCATION' then Text:= 'Laguna, California';

  if FieldName = 'NAME' then Text:= '7148317879';

  {special formatting}

  if Format = tfPhone then begin

    Insert(Text,'(',1);

    Insert(Text,')',5);

    Insert(Text,'-',9);

    end;

end;

The field labels provide an alternative to dropping on labels in Delphi.  The only drawback is that they cannot be connected to a database directly.


FieldsTo Method

Unit

Rfm

Applies to

TRFM

Declaration

procedure FieldsTo(MyCanvas:TCanvas; MyRect: TRect);

Description

The FieldsTo method will draw RFM fields to a Canvas directly.  An alternative is to use the AutoFields property, and PrintTo method.  Data is placed in the Fields using the OnPrintField event.


FillList Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property FillList : TStrings;

Description

During form-filling, the TRFMImage component will recognize any TLabel components dropped on top of it.  If the AutoFill property is true, the labels will be scaled and printed.  The FillList property is a list of types of Labels recognized during filling.  Several defaults have already been set.  Any components added to the list must be a descendant of a TLabel or TDBLabel.


FillTo Method

Unit

Rfm

Applies to

TRFM

Declaration

procedure FillTo(MyCanvas:TCanvas; MyRect: TRect);

Description

The FillTo method will draw scaled text labels to a Canvas directly.  An alternative is to use the AutoFill property, and PrintTo method.


Form-Filling Concepts


Height Property

Unit

Rfm

Applies to

TRFM

Declaration

property Height: smallint

Description

The height property returns the height of the loaded RFM in pixels.


LoadFromStream Method

Unit

Rfm

Applies to

TRFM, TRFMImage

Declaration

procedure LoadFromStream(Stream: TStream);

Description

Loads an RFM from a stream.


LoadfromFile Method

Unit

Rfm

Applies to

TRFM, TRFMImage

Declaration

procedure LoadFromFile(FileName: String);

Description

Loads an RFM from a disk-file.


LogoList Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property LogoList : TStrings;

Description

During form-filling, the TRFMImage component will recognize any TImagel components dropped on top of it.  If the AutoLogo property is true, the images will be scaled and printed.  The LogoList property is a list of types of Images recognized during filling.  Several defaults have already been set.  Any components added to the list must be a descendant of a TImage or TDBImage.


LogoTo Method

Unit

Rfm

Applies to

TRFM

Declaration

procedure LogoTo(MyCanvas:TCanvas; MyRect: TRect);

Description

The LogoTo method will draw scaled image logos to a Canvas directly.  An alternative is to use the AutoLogo property, and PrintTo method.


Metafile
A Metafile is a standard windows "drawing record" containing all the necessary commands to draw a picture.  Realforms V2.0 required you to export a metafile and use it in your programs.  We (and our users) have found metafiles to be larger, slower, and incompatible between 32-bit Windows.  We strongly suggest using the RFM components in place of metafiles.


OnChange Event

Unit

Rfm

Applies to

RFM, TRFMImage

Declaration

property OnChange(Sender: TObject);

Description

Occurs whenever a change occurs in the RFM data.  Normally during Loading.


OnPrintField event

Unit

Rfm

Applies to

TRFMImage

Declaration

property OnPrintField(Sender: TObject; FieldName: string; Format: TTextFormat; var Text: string);

Description

Occurs whenever an RFM with field labels is being drawn.  By checking the FieldName value, you can then put the appropriate text in the Text property.  TTextFormats are provided to  handle special formatting.

Example:  Filling a form using RFM Field Labels


Print Method

Unit

Rfm

Applies to

TRFMImage

Declaration

procedure Print;

Description

The print method will draw the RFM on the active printer canvas, filling labels and logos if the AutoFill and AutoLogo properties are true.  The printer orientation and paper size will be automatically defaulted.


PrintTo Method

Unit

Rfm

Applies to

TRFMImage

Declaration

procedure PrintTo(MyCanvas:TCanvas; MyRect: TRect);

Description

The PrintTo method will draw the RFM on the designated canvas, filling labels and logos if the AutoFill and AutoLogo properties are true.  The image will be scaled using MyRect.  If you do not wish to scale the image, send RFMRect as the TRect parameter (this is a full-size rectangle).


Product Registration

The RFM and RFMImage components are public domain.  You may distrubute them freely with your own programs.  To produce RFM files, you will need to register our form designer, RealForms.  A demo version of Realforms can be found on Compuserve, or on our web site at www.realsoftdev.com.  The price to register is currently $40.00 US.


RFM Data Format

The RFM data format is public domain.  You can use it to create your own RFM's from scratch, however we suggest using RealForms, our RFM designer.  RFM files consist of a header record, several object records, and a dynamic string table at the end.  The types and records are outlined below.

{************************}

{ RFM Record Definitions }

{      Version 2.1       }

{ Copyright 1997  R.S.D. }

{************************}

unit Rfmrec;

interface

uses Graphics;

type

        TDrawType    =  (dtNone, dtUnused, dtText, dtFrame, dtLine, dtCkBox, dtField);

        TLineType    =  (ltHorz, ltVert, ltDiagL, ltDiagR);

        TFillStyle   =  (fsClear, fsSolid, fsDiagonal, fsHash);

        TPageSize    =  (psLegal, psLetter, psA3, psA4, psA5);

        TOrientation =  (orPortrait, orLandScape);

        {----------Header Data----------}

        RFormHdr = packed record

          NumRecs               : smallint;

          PageSize              : TPageSize;

          Thick                 : byte;

          PStyle                : TPenStyle;

          Width                 : Word;

          Height                : Word;

          VersionMajor          : byte;

          VersionMinor          : byte;

          Orientation           : TOrientation;

          Unused                : array[0..86] of byte;

          end;

        {----------Object Data----------}

        RFormRec = packed record                                {Generic Record}

          DrawType               : TDrawType;

          Left                  : smallint;

          Top                   : smallint;

          Width                 : word;

          Height                : word;

          StrIdx1               : word;

          StrIdx2               : word;

          unused                : array[0..11] of byte;  {filler}

        end;

        RFormText = packed record

          DrawType              : TDrawType;

          Left                  : smallint;

          Top                   : smallint;

          Width                 : word;

          Height                : word;

          StrIdx                : word;

          FontIdx               : word;

          FontStyle             : TFontStyles;

          FontSize              : byte;

          Color                 : byte;

          Vert                  : boolean;

          unused                : array[0..7] of byte;  {filler}

          end;

        RFormFrame = packed record

          DrawType              : TDrawType;

          Left                  : smallint;

          Top                   : smallint;

          Width                 : word;

          Height                : word;

          PStyle                : TPenStyle;

          FStyle                : TFillStyle;

          Color                 : byte;

          LColor                : byte;

          Thick                 : byte;

          unused                : array[0..10] of byte;  {filler}

          end;

        RFormLine = packed record

          DrawType              : TDrawType;

          Left                  : smallint;

          Top                   : smallint;

          Width                 : word;

          Height                : word;

          PStyle                : TPenStyle;

          LType                 : TLineType;

          Color                 : byte;

          Thick                 : byte;

          unused                : array[0..11] of byte;  {filler}

          end;

        RFormCkBox = packed record

          DrawType              : TDrawType;

          Left                  : smallint;

          Top                   : smallint;

          Width                 : word;

          Height                : word;

          Color                 : byte;

          Thick                 : byte;

          unused                : array[0..13] of byte;  {filler}

          end;

        {-----------Field Data----------}

        RFormField = packed record

          DrawType              : TDrawType;

          Left                  : smallint;

          Top                   : smallint;

          Width                 : word;

          Height                : word;

          StrIdx                : word;

          FontIdx               : word;

          FontStyle             : TFontStyles;

          FontSize              : byte;

          Color                 : byte;

          Vert                  : boolean;

          Format                : byte;

          unused                : array[0..6] of byte;  {filler}

          end;

        RRFLField = packed record

          Left                  : smallint;

          Top                   : smallint;

          Vert                  : boolean;

          Format                : byte;

          Name                  : String[20];

          FontName              : String[32];

          FontStyle             : TFontStyles;

          FontSize              : byte;

          FontColor             : byte;

          end;

implementation

end.


RFM Events
OnChange


RFM Methods
Clear	LoadfromFile

ClearBMP	SavetoFile

Print	LoadFromStream

Draw	SaveToStream

ScaleDraw	SaveAsBitmap

DrawTo	SaveAsMetafile

Assign


RFM Properties
Width

Height

Empty

Canvas

Designing


RFM Property

Unit

Classes

Applies to

TMemoryStream

Declaration

property Memory: Pointer;

Description

The Memory property


RFM Protected
These variables internally store the rfm records and bitmap canvas.

You should never need to use them.

Bitmap-- internal bitmap canvas

Header--  rfm header record

Dynarray--  dynarray of rfm records

StrTable-- TStrings of rfm fonts and label text


RFM See Also
TRFMImage

RealForms


RFMImage Events
OnChange

OnPrintField


RFMImage Methods
Clear

RFMRect

PrintTo

FillTo

LogoTo

FieldsTo

SetPaperSize


RFMImage Properties
AutoSize

AutoFill

AutoLogo

Center

Stretch

Aspect

RFM

FillList

LogoList

Canvas


RFMImage See Also
TRFM

RealForms


RFMRect Method

Unit

Rfm

Applies to

TRFMImage

Declaration

function RFMRect:TRect

Description

The RFMRect method will return the bounding rectangle of the RFM.  This is actually (0,0,RFM.Width, RFM.Height).


Realform Form Files

Realforms is a complete form design and data-filling system.  Although it was not designed as a reporting tool, a form-based report generator is definitely possible using the system.  Realforms supports several pages sizes, and orientations for forms.  Forms are designed as sets of lines, frames, check boxes and text.  We are continually updating the program with features and additions.

RFM Files are the file format for these forms.  They contain a record header, object records, and a string-table containing text and font information.  The demo version of Realforms has a trial timer attached.

Realforms registration is currently $40.00 US.

You will receive all future updates and support after registration.

To order on Compuserve, type GO SWREG # 12706, or send E-mail to dan@realsoftdev.com.

Updates can also be found at www.realsoftdev.com or on Compuserve.

We can be reached by phone at (714) 831-7879.

A typical form being designed in RealForms.


SaveAsBitmap Method

Unit

Rfm

Applies to

TRFM

Declaration

procedure SaveAsBitmap(FileName: String);

Description

Saves a drawn RFM to a disk-file as a Bitmap.


SaveAsMetafile Method

Unit

Rfm

Applies to

TRFM

Declaration

procedure SaveAsMetaFile(FileName: String);

Description

Saves a drawn RFM to a disk-file as a MetaFile.


SaveToStream Method

Unit

Rfm

Applies to

TRFM, TRFMImage

Declaration

procedure SaveToStream(Stream: TStream);

Description

Saves an RFM to a stream.


SavetoFile Method

Unit

Rfm

Applies to

TRFM, TRFMImage

Declaration

procedure SaveToFile(FileName: String);

Description

Saves an RFM from to disk-file.


ScaleDraw Method

Unit

Rfm

Applies to

TRFM

Declaration

procedure ScaleDraw(MyRect: TRect);

Description

The ScaleDraw method will draw an RFM to its internal canvas, fitting it into MyRect.


SetPaperSize Method

Unit

RFM

Applies to

TRFMImage

Declaration

procedure SetPaperSize;

Description

The SetPaperSize method can be called before showing a print dialog to default the page size and orientation for the  currently loaded RFM.


Stretch Property

Unit

Rfm

Applies to

TRFMImage

Declaration

property Scale:boolean

Description

The Scale property, when set to true, will draw the RFM into the rectangle of the RFMImage, no matter what size it is.


TRFM Class

See Also     Properties     Methods     Events     Protected

Unit

Classes

Description

The TRFM Class is an abstract object providing access for reading, writing, converting and drawing a RealForm Form File.  Although the TRFM is usually used with its wrapper, the TRFMImage component,  it can be created and used separately if visual components are not required.  The most common methods used are LoadFromFile, SaveToFile, which read and write RFM files.  Once an RFM has been read, properties such as Width and Height are available.  To draw an RFM on its internal Canvas, call the Draw or ScaleDraw Methods.  The drawn image is contained in the Canvas property.  To draw on an exterrnal canvas, call the DrawTo method.  To convert the RFM to another windows format, call the SaveAsBitmap or SaveAsMetafile methods.  RFMs provide internal code necessary to read and write RFMs to stream such as Delphi form files.


TRFMImage Component

See Also     Properties     Methods     Events

Unit

Rfm.pas

Description

The TRFMImage component provides an easy to use visual wrapper to the TRFM class.  It works very similar to the TImage component provided with Delphi.  To load an RFM image, click on the ellipsis next to the RFM property.  A special dialog will allow you to browse for an RFM, showing a scaled preview of each.  RFMs are generated using the RealForms form design system.  You can change the way the loaded picture is displayed using properties such as AutoSize, Center, Stretch, and Aspect.  Form filling can be accomplished by dropping TLabels or TDBLabels on top of the RFMImage.  You can designate which types of label controls the RFMImage will recognize by changing the FillList property.  Common Labels have already been entered as defaults.  Logos can be added to the form by dropping a TImage or TDBImage component on top of the RFMImage.  The logos will be scaled and printed when the form is filled.   The RFMImage will recognize bitmaps, metafiles, and even other TRFMImages.  The LogoList property determines the types of Image controls recognized during logo filling.  RFMImages also support special fields that are contained in the actual RFM file, and are added with Realforms.  These fields can be filled using the OnPrintField event.

At runtime, you can read and write RFM's using LoadfromFile, SavetoFile, LoadfromStream, and SavetoStream.  You can access the drawing using the Canvas property.  To fill and print the RFM, call the Print method.  To fill and draw the rfm to any other canvas (such as a print preview), call the PrintTo method.  Filling with labels, fields or logos will only occur if the AutoFill , AutoFields, and  AutoLogo properties are set to true, respectively.

Example:  Implementing a Print Preview

Example:  Easy Form Filling

Example:  Form Filling using RFM Field Labels


TTextFormats
tfGeneral, tfInteger, tfReal, tfDollar, tfPhone, tfDate, tfCheck,

tfTime, tfCustom1, tfCustom2,tfCustom3,tfCustom4,tfCustom5,

tfCustom6,tfCustom7, tfCustom8,tfCustom9,tfCustom10,tfCustom11,

tfCustom12,tfCustom13, tfCustom14,tfCustom15


Width Property

Unit

Rfm

Applies to

TRFM

Declaration

property Width: smallint

Description

The width property returns the width of the loaded RFM in pixels.