Modifying the SDK DDE Server Example to Work with Excel

ID Number: Q69293

3.00

WINDOWS

Summary:

The sample dynamic data exchange (DDE) application provided in the

Microsoft Windows Software Development Kit (SDK) does not work

properly with Microsoft Excel when Excel makes a DDE request

(=REQUEST). The information below discusses the necessary changes to

the Server application to achieve compatibility with Excel.

More Information:

Excel uses the fResponse flag in the DDEDATA structure to distinguish

responses from WM_DDE_REQUEST and WM_DDE_ADVISE messages. If a DDE

server application responds to a WM_DDE_REQUEST message from Excel, it

must set the fResponse flag to TRUE. If a DDE server application

responds to a WM_DDE_REQUEST with the fResponse flag set to FALSE, the

Excel macro will wait until interrupted by the user.

The modifications to the Server application required for Excel

compatibility are described below.

The SendData() function in the sample application should be changed to

look like the following:

void SendData(HWND hwndServerDDE,

HWND hwndClientDDE,

char *szItemName,

char *szItemValue,

BOOL bDeferUpdate,

BOOL bAckRequest,

BOOL bAdviseResponse)

The new argument bAdviseResponse is set to TRUE when the data block to

be sent is a response to a WM_DDE_ADVISE message; otherwise, it is set

to FALSE.

After the data block is allocated, the response flag is set using:

lpData -> fResponse = !bAdviseResponse ;

These two changes are made in the SERVDDE.C file of the sample. All

other references to SendData() in SERVER.C, SERVER.H, or SERVDDE.C

should be modified to account for the new argument.