bool CDDELink::CopyLink(HWND hOwner, const CDDELink* pLink) { ASSERT(::IsWindow(hOwner)); ASSERT(pLink != nullptr); ASSERT(pLink->Conversation() != nullptr); CDDEConv* pConv = pLink->Conversation(); return CopyLink(hOwner, pConv->Service(), pConv->Topic(), pLink->Item()); }
void CNetDDESvrApp::OnAdvise(CDDELink* pLink, const CDDEData* pData) { ASSERT(pData != NULL); // Ignore Advise, if during an Advise Start. if (pLink == NULL) return; CDDEConv* pConv = pLink->Conversation(); CBuffer oData = pData->GetBuffer(); // Find the links' value in the cache. CLinkValue* pValue = m_oLinkCache.Find(pConv, pLink); // Discard duplicate updates. if ((App.m_bDiscardDups) && (pValue != NULL) && (pValue->m_oLastValue == oData)) { if (App.m_bTraceUpdates) App.Trace(TXT("DDE_ADVISE: %s %s (ignored)"), pConv->Service(), pLink->Item()); return; } // Create a cache entry, if a new link. if (pValue == NULL) pValue = m_oLinkCache.Create(pConv, pLink); ASSERT(pValue != NULL); // Update links' cached value. pValue->m_oLastValue = oData; pValue->m_tLastUpdate = CDateTime::Current(); // Create advise packet. HCONV hConv = pConv->Handle(); CBuffer oBuffer; CMemStream oStream(oBuffer); oStream.Create(); oStream.Write(&hConv, sizeof(hConv)); oStream << pLink->Item(); oStream << (uint32) pLink->Format(); oStream << oData; oStream << true; oStream.Close(); CNetDDEPacket oPacket(CNetDDEPacket::DDE_ADVISE, oBuffer); // Notify all NetDDEClients... for (size_t i = 0; i < m_aoConnections.Size(); ++i) { CNetDDESvrSocket* pConnection = m_aoConnections[i]; // Ignore, if connection severed. if (!pConnection->IsOpen()) continue; // Connection references link? if (pConnection->IsLinkUsed(pLink)) { try { if (App.m_bTraceUpdates) { uint nFormat = pLink->Format(); CString strData; if (nFormat == CF_TEXT) strData = oData.ToString(ANSI_TEXT); else if (nFormat == CF_UNICODETEXT) strData = oData.ToString(UNICODE_TEXT); else strData = CClipboard::FormatName(nFormat); App.Trace(TXT("DDE_ADVISE: %s %s [%s]"), pConv->Service(), pLink->Item(), strData); } // Send advise message. pConnection->SendPacket(oPacket); // Update stats. ++m_nPktsSent; } catch (CSocketException& e) { App.Trace(TXT("SOCKET_ERROR: %s"), e.twhat()); } } } }