13-22
Dynamic Data Exchange
This needs to be extracted from the DDEDATA message in order to read the
appropriate values. One way of doing this is shown below.
/
****************************************************************
FUNCTION: ClientReceiveData
PURPOSE: Called when client application receives WM_DDE_DATA message.
****************************************************************/
void
ClientReceiveData(hwndClientDDE, hwndServerDDE, lParam)
HWND hwndClientDDE;
HWND hwndServerDDE;
LONG lParam;
{
DDEDATA FAR * lpDDEData;
LPDDE_CURSINF lpDdeCursInf;
BOOL bRelease;
BOOL bAck;
if (!(lpDDEData = (DDEDATA FAR *)GlobalLock(LOWORD(lParam))) ||
(lpDDEData->cfFormat != CF_TEXT))
{
PostMessage(hwndServerDDE,
WM_DDE_ACK, hwndClientDDE,
MAKELONG(0, HIWORD(lParam))); /* Negative ACK */
}
else
{
/* Read Row/Column values in static vars */
lpDdeCursInf = (LPDDE_CURSINF)lpDDEData->Value;
CurrentCursRow = lpDdeCursInf->Row;
CurrentCursCol = lpDdeCursInf->Col;
if (lpDDEData->fAckReq)
{ /* return ACK or NACK */
PostMessage(hwndServerDDE,
WM_DDE_ACK,
hwndClientDDE,
MAKELONG( (bAck? 0x8000:0),
HIWORD(lParam)));
}
bRelease = lpDDEData->fRelease;
GlobalUnlock(LOWORD(lParam));
if (bRelease)
GlobalFree(LOWORD(lParam));
}
return;
}