TDB2Web - Developer's reference

  1. To implement in an app - Example
  2. Public properties
  3. Constructor / methods
  4. Required files
  5. Dialogues overview
  6. Windows registry entries
  7. Technical reference

Example

This control is not a component and therefore cannot be picked from the gallery, it is quite easy to implement, though:
Simply create an OnClick-event for a menu item or a button, insert a few lines of code which creates a TDB2Web object and executes it, and that's it.

The example below demonstrates the usage of all exported, i.e. accessable instance variables. To get a closer information about them, just click on the desired one.

procedure TDemoGridForm.Table2HTMLItemClick(Sender: TObject);
var sFileName: String;
begin
  with ( TDB2Web.Create( self, HKEY_CURRENT_USER,
                     'SOFTWARE\Your Company\Your Application' ) ) do try

    { required }
    DataGrid := self.MyGrid;           // sets DataSource and DataSet
                                       // automatically

    { optional }
    ExportDir := '\temp\export\';      // sets the (local) export path
    ShowSetup := True;                 // brings up the setup dialogue
    ShowPage := True;                  // displays the created HTML-page
    PatternFile := 'MySweetHomepage.html'; // name of the pattern file
    OutputFile := 'Smiley';            // name of the output file
    HelpFileLoc := '';                 // location of the helpfile

    if ( Exec() ) then                 // fires up the publisher
      sFileName := Outputfile;         // gets the name of the output file
  finally
    Free();
  end;
end;

Notice that some Hint-messages are prepared to pass an OnHint-event. The demo application provides such an event that displays the hint in the StatusBar.


Public properties index

 o = required,  o = optional,  o = write only

Note: There can only be one data source, so the datasource-properties (marked green) are to be used alternatively.

 o DataGrid

Sets the datasource to a TDBGrid.

 o DataSource

Sets the datasource to a TDataSource.

 o DataSet

Sets the datasource to a TDataSet (TQuery or TTable).

 o ExportDir

Sets / gets the (local) directory where the created files are stored.

 o HelpFileLoc

Sets the location of the publisher's helpfile.

 o OutputFile

Sets / gets the name of the created file.

 o PatternFile

Sets / gets the name of the pattern file.

 o ShowPage

Determines whether to show the created HTML-page after export.

 o ShowSetup

Determines whether to bring up the setup dialogue.

Public properties

 o = required,  o = optional,  o = write only

 o DataGrid

Purpose

Sets the publisher's datasource to a TDBGrid.

Type

TDBGrid

Default

none

Note

The grid's DataSource-property must be accessable; and the datasource's DataSet- property must also be accessable.

Example:

oDB2Web.DataGrid := self.MyGrid;

 o DataSource

Purpose

Sets the publisher's datasource to a TDataSource.

Type

TDataSource

Default

none

Note

The datasource's DataSet-property must be accessable.

Example:

oDB2Web.DataSource := self.MySource;

 o DataSet

Purpose

Sets the publisher's datasource to a TDataSet (TQuery or TTable).

Type

TDataSet

Default

none

Note

-

Example:

oDB2Web.DataSet := self.MyQuery;

 o ExportDir

Purpose

Sets / gets the (local) directory where the created files are stored.

Type

String

Default

none

Notes

  • If nothing else is specified the HTML-file and all attached memo files and graphic files will be exported to the current directory.
  • If the directory does not exist it will be created. You will be informed if the creation fails, and export will not process.
  • Closing backslash is required.

Example:

oDB2Web.ExportDir := '\temp\';
sets the directory to the TEMP-path of the current drive.

 o HelpFileLoc

Purpose

Sets the the path, where the user's helpfile DB2WEB.HLP is located.

Type

String

Default

.\Help\

Notes

  • Closing backslash is required.
  • To set the location to the application's path, assign an empty string.
  • Name of the helpfile is DB2WEB.HLP.

Example:

oDB2Web.HelpFileLoc := '.\WinHelp\';
sets the location of the helpfile to the WINHELP-subdirectory of the current directory.

 o OutputFile

Purpose

Sets / gets the name of the output file.

Type

String

Default

Basic name of the given dataset plus the extension .HTM

Notes

  • The default will be retrieved either from the DOS-name of the table (if it is a TTable) or from the name given in the SQL-SELECT- statement.
  • If the name has more than eight characters, it will simply be cut off.
  • On writing to the property directory qualifiers will be cut off. To set the output directory use the ExportDir-property.
  • The extension will be replaced by .HTM.
  • The property's read-result is a fully qualified file name including the current ExportDir-value.

Examples:

oDB2Web.OutputFile := 'Smiley';
oDB2Web.ExportDir := '\temp\';
sFileName := oDB2Web.OutputFile; // result is '\temp\Smiley.htm'
 
oDB2Web.DataSet := self.MyQuery; // SQL is: SELECT * FROM RhabarberRhabarber R JOIN..
oDB2Web.ExportDir := '.\output\';
sFileName := oDB2Web.OutputFile; // result is '.\output\Rhabarbe.htm'

See also:

General file naming and Output restrictions

 o PatternFile

Purpose

Sets / gets the name of the pattern file (if any)

Type

String

Default

Pattern.htm

Notes

TDB2Web expects an HTML-based pattern file for its work. If no pattern file is specified, the default one will be used. If this does not exist, it will be created.

Example:

oDB2Web.PatternFile := 'MySweetHomepage.htm'

See also:

How to prepare a pattern file

 o ShowPage

Purpose

Determines whether to show the created HTML-page after export.
If the page is not to be shown, the user will be informed by a simple info window that the page has been created (if so!). This window disappears after a period of ten seconds.

Type

Boolean

Default

True

Note

If the value is True the currently selected browser will be fired up (Shareware version: in-build only).

Example:

oDB2Web.ShowPage := False;

 o ShowSetup

Purpose

Determines whether to bring up the setup dialogue.

Type

Boolean

Default

True

Note

If the setup is not shown, export happens with the settings read from Windows registry.

Example:

oDB2Web.ShowSetup := False;

Constructor / methods

constructor TDB2Web.Create(AOwner: TComponent;
                                rKey: HKey;
                                rPath: String);

Arguments

AOwner  TComponent  Owner of the object
rKeyHKeySets the registry key where to store and restore settings for TDB2Web (should be HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER)
rPathStringSets the registry path within rKey where to store and restore settings for TDB2Web.

See example for usage.

function TDB2Web.Exec: Boolean

Purpose
Main execution loop
Returns
boolean - False if an error occurred, True if not

See example for usage.


Windows registry entries