LabWindows/CVI

Content Type
Programming Language
Current manual

DDE Callback Function

DDE Callback Function

Callback functions provide the mechanism for sending and receiving data to and from other applications through DDE. A DDE callback function responds to incoming DDE information in a way that is similar to the method in which a callback function responds to user interface events.

A DDE callback function in a client application can respond to only two types of DDE messages: DDE_DISCONNECT and DDE_DATAREADY. If you set up a warm link or hot link, also called an advisory loop, the DDE_DATAREADY message calls the callback function you specify in ConnectToDDEServer whenever the data values change in the server application.

A DDE callback function in a server application can be triggered in a number of ways. Whenever a client application attempts to connect to your server program or requests information from your program, your program executes the callback function to process the request. The parameter prototypes for the DDE callback functions in LabWindows/CVI are defined as follows:

int CallbackFunction (int handle, char *topicName, char *itemName, int xType, int dataFmt, int dataSize, void *dataPtr, void *callbackData);

Parameters

Name Type Description
handle integer Conversation handle that uniquely identifies the client-server connection.
topicName char pointer Server application that triggers the callback.
itemName char pointer Data item within the server application that triggers the callback. There is an exception: when xType is DDE_EXECUTE, itemName represents the command string from the client program.
xType integer Transaction type.
dataFmt integer Format of the data being transmitted.
dataSize integer Number of bytes in the data. Might actually be greater than the number of bytes transmitted. You should encode size information in your data.
dataPtr void pointer Pointer that points to the transmitted data.
callbackData void pointer User-defined data value.
Note   The value of the dataSize parameter is greater than or equal to the actual size of the data. Encode more exact size information in your data.

Return Value

The callback function returns 1 to indicate success or 0 to indicate failure or rejection of the requested action.

Transaction Types

The following table lists all the DDE transaction types, xType, that can trigger a callback function.

DDE Transaction Types (xType)

xType Server Can Respond To? Client Can Respond To? When?
DDE_CONNECT Y N When a new client requests a connection.
DDE_DISCONNECT Y Y When a conversation partner quits.
DDE_DATAREADY Y Y When a conversation partner sends data.
DDE_REQUESTDATA Y N When a client requests data.
DDE_ADVISELOOP Y N When a client requests an advisory loop.
DDE_ADVISESTOP Y N When a client terminates a request for an advisory loop.
DDE_EXECUTE Y N When a client requests the execution of a command.

Refer to the descriptions for RegisterDDEServer and ConnectToDDEServer for more information about the DDE callback function.

Was this information helpful?