13-7
Dynamic Data Exchange
Data Transmission Over A Slave DDE Link
Once initiated, TeemTalk enters Slave mode, diverting all input from the keyboard, for
example to the Client application, and permitting data to be sent to it from the Client.
Data coming from TeemTalk will be sent in the form of a DDE POKE message. A
suitable way of accepting this is outlined below.
DDEWndProc(HWND hWnd, unsigned message, WORD wParam, LONG lParam)
{
.
.
switch (message)
{
.
.
case WM_DDE_POKE:
ClientReceivedPoke(hWnd, (HWND)wParam, lParam);
break;
.
.
}
.
.
}
ClientReceivedPoke(
HWND hWnd,
HWND hWndPartnerDDE,
LONG lParam
)
{
HANDLE hPokeData;
DDEPOKE FAR * lpPokeData;
ATOM atomItem;
char szItemName[ITEM_NAME_MAX_SIZE];
hPokeData = LOWORD(lParam);
atomItem = HIWORD(lParam);
GlobalGetAtomName(atomItem, szItemName, ITEM_NAME_MAX_SIZE);
if (!(lpPokeData = (DDEPOKE FAR *)GlobalLock(hPokeData))
|| lpPokeData->cfFormat != CF_TEXT
|| (PartnerSentData(szItemName, lpPokeData->Value) == FALSE))
{
PostMessage(hWndPartnerDDE, WM_DDE_ACK, hWnd,
MAKELONG(0, atomItem));
return;
}
/* Save value of fRelease, since pointer may be invalidated
by GlobalUnlock */
bRelease = lpPokeData->fRelease;