How Tos
Last reviewed: 7/15/2011
Article ID: H071118
HOW: Developing C++Builder applications that manage lexicons
The information in this article applies to:
- LexiconKit 4
Summary
You can develop C++Builder applications that manage lexicons using your favorite version of C++Builder.
More Information
LexiconKit includes C++Builder header files comprised of the C++Builder classes that manage grammars and automatically load and unload the runtime DLL.
To access the LexiconKit C++Builder classes within your application, first add a project reference to the C++Builder header include files:
- Within your C++Builder project, select Project Options.
- Select the C++Builder compiler options
- Add Include path reference to the LexiconKit header files directory: C:\Program Files\Chant\LexiconKit 4\Win32\CBuilder\include
To access the LexiconKit C++Builder classes within your application, add a reference to the LexiconKit Header file in your C++Builder application header file:
#include "cchantlm.h"
Add a reference in your C++Builder application source file to the LexiconKit code needed to dynamically load and unload the runtime DLL:
#include "CChantLexiconKit.cpp"
Object Instantiation
Declare a global variable for the ChantLM class, instantiate an instance, set the license and serial properties, and set the event handler message.
Add the following to your application header file:
protected: void __fastcall OnHasEvent(TMessage& msg); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_APP+5, TMessage, OnHasEvent); END_MESSAGE_MAP(TForm) private: // User declarations CChantLM* ChantLM1;
Add the following to your application source file:
ChantLM1 = new CChantLM(); // Set license properties ChantLM1->SetStringProperty(CSPLicense,"LicenseRegistrationNumber"); ChantLM1->SetStringProperty(CSPSerials,"LicenseSerialNumber"); // Define the HasEvent callback message ChantLM1->SetWindowMessage(Handle, WM_APP+5, 0, 0);
Event Callbacks
Event callbacks are the mechanism in which the component library sends information back to the application such as phoneme selection, import/export processing state, or there was an error.
void __fastcall TForm1::OnHasEvent(TMessage& msg) { int numberOfEvents = ChantLM1->GetResourceCount(CSREvent,0,0); for (int i = 0; i < numberOfEvents; i++) { // Get the event from the event queue CChantLMEvent* pEvent = ChantLM1->GetChantLMEvent(0); switch (pEvent->GetChantCallback()) { default: break; case CCSRProgress: { ... break; } } ... // Remove the event from the event queue ChantLM1->RemoveResource(CSREvent,0,0,""); delete pEvent; } }
Deployment Checklist
When you are ready to deploy your C++Builder 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 C++Builder application to any system with a valid license from the Chant.
- Copy CLexiconKit.dll to the target system and place in the same directory with your application.
Sample Projects
C++Builder sample projects are installed at the following location:
- My Documents\Chant LexiconKit 4\Win32\CBuilder\RS 2007,
- My Documents\Chant LexiconKit 4\Win32\CBuilder\RS 2009,
- My Documents\Chant LexiconKit 4\Win32\CBuilder\RS 2010,
- My Documents\Chant LexiconKit 4\Win32\CBuilder\RS XE, and
- My Documents\Chant LexiconKit 4\Win32\CBuilder\RS XE2.