Borland Delphi Interface
TE Developer's kit includes a OCX (toc30.ocx) which can be used with a 32 bit Delphi application. Please refer to the chapter on ActiveX Control for a complete description of the properties and events for this control. Every property except the 'data' property is accessible to a Delphi application. Instead, for data input and output, a Delphi application should use the SetTerBuffer and GetTerBuffer functions (described later in this function). In addition to these two functions, all other DLL functions are also available for use with a Delphi application.
The package contains two Delphi interface files: TER.PAS and TER_PROT.PAS. The TER.PAS file contains the constant and record declarations. This file should be included in the interface section of a unit after the type declaration for the form. The TER_PROT.PAS file contains the function declarations. This file should be included in the 'Implementation' section of your program unit.
Example:
Interface
uses ....
type ...
...
...
end;
{$I TER.PAS}
Implementation
{$I TER_PROT.PAS}
Please also refer to the demo application contained in the DELPHI.ZIP file.
Inserting text into the editor control: As mentioned earlier, the SetTerBuffer function is used to insert text into the control. The following example reads the data from a disk file and inserts into the control:
var
InFile : file;
FileLength: Integer;
BytesRead: Integer;
hMem: THandle;
pMem: PChar;
begin
{ open a TER data file}
AssignFile(InFile,'DATA.TER');
Reset(InFile,1);
FileLength:=FileSize(InFile);
{allocate space for the input buffer}
hMem:=GlobalAlloc(GMEM_MOVEABLE,FileLength+1);
pMem:=GlobalLock(hMem);
{Read the file into the input buffer.
The pointer is passed as pMem[0] because
the buffer argument is passed by reference}
BlockRead(InFile,pMem[0],FileLength,BytesRead);
CloseFile(InFile);
{unlock the buffer and transfer to TER control}
GlobalUnlock(hMem);
SetTerBuffer(ter1.handle,hMem,FileLength,'',True);
end;
Retrieving text from the edit control: Your application uses GetTerBuffer to retrieve text and formatting information from the control. Example:
var
hMem: THandle;
TextLength: LongInt;
begin
{retrieve the text}
hMem:=GetTerBuffer(ter1.handle,TextLength);
end;