How do I develop Delphi applications that manage grammars?
Last reviewed: 12/15/2011
HOW Article ID: H071112
The information in this article applies to:
- GrammarKit 4
Summary
You can develop Delphi applications that manage grammars using your favorite version of Delphi.
More Information
GrammarKit includes a Delphi Pascal source file GrammarKit.pas comprised of the Delphi classes that manage grammars. It also includes a Delphi Pascal source file ChantShared.pas comprised of common Delphi classes that all Chant libraries use.
To access the GrammarKit Delphi classes within your application, first add a project reference to the GrammarKit Delphi source file:
- Within your Delphi project, select Project Options.
- Select the Delphi compiler options.
- Add Search path reference to the GrammarKit unit source file directory: C:\Program Files\Chant\GrammarKit 4\Win32\Delphi\source.
- Add unit output path reference to the local directory with a period '.' character.
- Within your Delphi project, select Project Options.
- Select the Delphi compiler options.
- Add Search path reference to the GrammarKit unit source file directory: C:\Program Files\Chant\GrammarKit 4\Win64\Delphi\source.
- Add unit output path reference to the local directory with a period '.' character.
To access the GrammarKit Delphi classes within your application, add a reference to the ChantShared and GrammarKit units in your uses clause:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ChantShared, GrammarKit;
Add an event handler declaration and Object instance variable to the application declarations:
type
TForm1 = class(TForm)
...
private
{ Private declarations }
public
{ Public declarations }
procedure OnHasEvent(var msg: TMessage);
message WM_APP+4;
end;
var
Form1: TForm1;
ChantGM1: TChantGM;
Object Instantiation
Instantiate an instance, set the license and serial properties, and set the event handler message.
procedure TForm1.FormCreate(Sender: TObject);
begin
ChantGM1 := TChantGM.Create();
// Set license properties
ChantGM1.SetStringProperty(CSPLicense,'LicenseRegistrationNumber');
ChantGM1.SetStringProperty(CSPSerials,'LicenseSerialNumber');
// Define the HasEvent callback message
ChantGM1.SetWindowMessage(Handle, WM_APP+4, 0, 0);
end;
Event Callbacks
Event callbacks are the mechanism in which the component library communications information back to the application such as compilation is complete or there was an error.
procedure TForm1.OnHasEvent(var msg: TMessage);
var
aTChantGMEvent: TChantGMEvent;
i: Integer;
begin
numberOfEvents := ChantGM1.GetResourceCount(CSREvent,0,0);
for i := 0 to numberOfEvents - 1 do
begin
// Get the event from the event queue
aTChantGMEvent := ChantGM1.GetChantGMEvent(0);
case tEvent.ChantCallback of
CCGMDone:
...
end;
...
// Remove the event from the event queue
ChantGM1.RemoveResource(CSREvent);
aTChantGMEvent.Destroy();
end;
end;
Deployment Checklist
When you are ready to deploy your Delphi application, you need to ensure you have a valid license, bundle the correct Chant component library, and configure your installation properly on the target system. Review the following checklist before deploying your applications:
- You may deploy your Delphi application to any system with a valid license from the Chant.
- Copy CGrammarKit.dll to the target system and place in the same directory with your application.
- You may deploy your Delphi application to any system with a valid license from the Chant.
- Copy CGrammarKitX64.dll to the target system and place in the same directory with your application.
Sample Projects
Delphi sample projects are installed at the following location:
- My Documents\Chant GrammarKit 4\Win32\Delphi\RS 2007,
- My Documents\Chant GrammarKit 4\Win32\Delphi\RS 2009,
- My Documents\Chant GrammarKit 4\Win32\Delphi\RS 2010,
- My Documents\Chant GrammarKit 4\Win32\Delphi\RS XE,
- My Documents\Chant GrammarKit 4\Win32\Delphi\RS XE2, and
- My Documents\Chant GrammarKit 4\Win32\Delphi\RS XE3.
- My Documents\Chant GrammarKit 4\Win64\Delphi\RS XE2 and
- My Documents\Chant GrammarKit 4\Win64\Delphi\RS XE3.