
Adobe Acrobat SDK
Working with Host Function Tables
Developing Plug-ins and Applications
Creating HFT callback functions 168
Creating HFT callback functions
You must create an HFT callback function in order to successfully export an HFT. It is recommended that
you place the application logic to create an HFT callback in the
PluginExportHFTs
method. This is a
handshaking method that enables your plug-in to export an HFT. For information about handshaking, see
“Handshaking and Initialization” on page 28
.
To create an HFT callback function, declare an HFT
ServerProvideHFTProc
object that represents the
callback:
HFTServerProvideHFTProc provideMyHFTCallback
HFTServerProvideHFTProc
is a callback for an HFT server. After you create an
HFTServerProvideHFTProc
object, you can invoke the
ASCallbackCreateProto
macro to convert
a user-defined function to an HFT callback function. For example, you can invoke
ASCallbackCreateProto
to convert a user-defined function named
ProvideMyHFT
to a callback
function.
The
ASCallbackCreateProto
macro requires the following arguments:
●
The callback type. In this situation, specify
HFTServerProvideHFTProc
.
●
The address of the user-defined function that you want to convert to a callback function.
The
ASCallbackCreateProto
macro returns a callback of the specified type that invokes the
user-defined function whose address was passed as the second argument. The following lines of code
show the
ASCallbackCreateProto
macro converting the
ProvideMyHFT
user-defined function to a
PDWordProc
callback.
HFTServerProvideHFTProc provideMyHFTCallback =
ASCallbackCreateProto(HFTServerProvideHFTProc, &ProvideMyHFT);
The callback function is invoked when another plug-in attempts to use the HFT. After you create an HFT
callback function, you can invoke the
HFTServerNew
method to obtain an HFT
Server
object, which is
responsible for handling requests to obtain or destroy its HFT. An
HFTServe
r object is required in order to
create a new
HFT
object.
The
HFTServerNew
method requires the following arguments:
●
A character pointer that specifies the name of the HFT server. An HFT server name is used to import the
HFT. For information, see
“Importing an existing HFT” on page 173
.
●
An
HFTServerProvideHFTProc
object that specifies the HFT callback function.
●
An
HFTServerDestroyProc
object that specifies the HFT callback function that releases memory
from the HFT. This argument is optional and you can specify
NULL
.
●
A pointer to user-supplied data to pass to the HFT server. This argument is optional and you can specify
NULL
.
The following code example creates an HFT callback function within the
PluginExportHFTs
method.
After the
HFTServerProvideHFTProc
object is created, the
HFTServerNew
method is invoked which
creates an
HFTServer
object.
Example 16.1
Creating an HFT callback function
ACCB1 ASBool ACCB2 PluginExportHFTs(void)
{
gMyHFT = NULL;
gMyHFTServer = NULL;