The client application initiates a DDE conversation by calling WinDdeInitiate, specifying the server application-name string and the topic-name string.
The sample client application in "Sample Code for Dynamic Data Exchange" allows the user to initiate a DDE conversation from a context menu. The following code fragment shows how the client application processes that request:
/* User starts DDE conversation */
case IDM_POLL:
WinPostMsg(hListWnd, LM_DELETEALL, 0, 0);
ShowMessage("Polling...");
context.cb = sizeof(CONVCONTEXT);
context.fsContext = 0;
WinDdeInitiate(hwnd, szApp, szTopic, &context);
ShowMessage("Polling complete.");
break;
The following sample code shows how the server application determines whether to send a positive or negative acknowledgment to the WinDdeInitiate call:
/*********************************************************************/
/* Check incoming poll - if the App and Topic match, */
/* we must acknowledge. If both are zero-length, the client is */
/* searching for anyone to talk to - send our names */
/*********************************************************************/
szClientApp = pDDEinit->pszAppName;
szClientTopic = pDDEinit->pszTopic;
ShowMessage(szClientApp);
ShowMessage(szClientTopic);
if (!strcmpi(szClientApp, szApp) ||
!strcmpi(szClientApp, NULL))
{
if (!strcmpi(szClientTopic, szTopic) ||
!strcmpi(szClientTopic, NULL))
{
context.cb = sizeof(CONVCONTEXT);
context.fsContext = 0;
WinDdeRespond(hClientWnd,
hwnd,
szApp,
szTopic,
&context);
}
}
break;