Programmer Reference : Dynamic data exchange : Callbacks for handling DDE events
Callbacks for handling DDE events
Each DdeClient and DdeServerManager expects to have an application handle the DDE events as they occur (unless default processing is used). These events are handled by callbacks. For each possible DDE event, the application that creates a DdeClient or DdeServerManager registers one of its methods as the callback to handle that event. To register a callback, the application sends the message addCallback:receiver:selector:clientData: to the respective DdeClient or DdeServerManager.
The callback argument of this message identifies the particular DDE event that is to be hooked. The receiver argument identifies the object that will be sent the callback message, which is specified with the three-parameter message selector in the selector argument. The clientData argument specifies optional data that is passed to the callback method when it is run. The names identifying the DDE events, or callbacks, are defined in the pool dictionary DdeConstants. The following table identifies the callback names for the DdeServerManager.
Table 45. DdeServerManager callbacks
A client is requesting to terminate a link to an item.
A client is creating a warmlink to a data item.
A client is creating a hotlink to a data item.
A client is sending data to the server.
A client is trying to establish a connection to the server.
A client is requesting the server to run a command.
A client is requesting data from the server.
The client is terminating the connection with the server.
The following table identifies the callback names for the DdeClient.
Table 46. DdeClient callbacks
The item at the server has changed. The client must request the data from the server.
The item at the server has changed and the data is available from the DdeCallbackData object through the data message.
The server is terminating the connection with the client.
Thus, to set up a DdeServerManager to handle the DDE run callback, use code like the following:
addCallback: DdeNexecuteCallback
receiver: self
selector: #execute:clientData:callData:
clientData: nil.
All DDE callbacks are handled in the same manner as Common Widget callbacks. When a callback runs, its first parameter is the particular DdeServer or DdeClient object that originated the event; the second parameter is the client data object that was provided when the callback was registered; and the last parameter is a DdeCallbackData object that contains the information about the event (that is, any data associated with the event), the current server name, the current topic, and so on. From the example above, the callback method that responds to the DDE run event looks like this:
execute: aDdeServer clientData: clientData callData: callData
"A client has asked to run a command. Print the command in the
transcript and set the return value to true to indicate that the
command was run."
show: ('Execute : %1' bindWith: callData execute).
callData returnValue: true.
Last modified date: 01/29/2015