National Instruments 320682C Musical Toy Instrument User Manual


 
DDE Library Chapter 6
LabWindows/CVI Standard Libraries 6-14 © National Instruments Corporation
clientCallbackFunction defines a callback function through which all messages from the server
will be routed.
The callback function must be of the following form:
int (*ddeFuncPtr) (int handle, char *topicName, char *itemName,
int xType, int dataFmt, int dataSize,
void*dataPtr, void *callbackData);
The xType (transaction type) parameter specifies the type of message received from the server.
The clientCallbackFunction can receive only two transaction types: DDE_DISCONNECT and
DDE_DATAREADY.
DDE_DISCONNECT—Received when a server is requesting the termination of a connection, or
when Windows terminates the connection due to an internal error.
DDE_DATAREADY—Received when you have already set up a hot or warm link by calling
SetUpDDEHotLink or SetUpDDEWarmLink, and the server notifies you that new data is
available. (If the server program uses the LabWindows/CVI DDE Library, it notifies you by
calling AdviseDDEDataReady or BroadcastDDEDataReady.) The data is received in
the callback in the dataPtr parameter. The topicName, itemName, dataFmt, dataSize, and
dataPtr parameters contain significant data. The itemName can specify an object to which the
data refers. For example, in Excel, the item name specifies a cell. The dataFmt is one of the
Windows-defined data types, for example, CF_TEXT. The dataSize specifies the number of
bytes in the data pointed to by dataPtr.
Note: The dataSize value is the value LabWindows/CVI receives from Microsoft Windows.
This value can be larger than the actual number of bytes written by the client.
Note: The callback function should return TRUE if the message can be processed
successfully. Otherwise, it should return FALSE. The callback function should be
short and return as soon as possible.
callbackData is a four-byte value that will be passed to the callback function each time it is
called for this client.
You can define the meaning of the callback data. For example, you can use the callback data as a
pointer to a data object that you need to access in the callback function. In this way, you would
not need to declare the data object as a global variable.
If you do not want to use the callback data, you can pass zero.
Note: In the case of DDE_DISCONNECT, the value of callbackData is undefined.
See Also
DisconnectFromDDEServer, RegisterDDEServer