void MyServer::Advise() { if (CanAdvise()) { wxString s = wxDateTime::Now().Format(); m_connection->Advise(m_connection->m_sAdvise, (wxChar *)s.c_str()); s = wxDateTime::Now().FormatTime() + _T(" ") + wxDateTime::Now().FormatDate(); m_connection->Advise(m_connection->m_sAdvise, (wxChar *)s.c_str(), (s.Length() + 1) * sizeof(wxChar)); #if wxUSE_DDE_FOR_IPC wxLogMessage(_T("DDE Advise type argument cannot be wxIPC_PRIVATE. The client will receive it as wxIPC_TEXT, and receive the correct no of bytes, but not print a correct log entry.")); #endif char bytes[3]; bytes[0] = '1'; bytes[1] = '2'; bytes[2] = '3'; m_connection->Advise(m_connection->m_sAdvise, (wxChar *)bytes, 3, wxIPC_PRIVATE); // this works, but the log treats it as a string now // m_connection->Advise(m_connection->m_sAdvise, (wxChar *)bytes, 3, wxIPC_TEXT ); } }
void MyServer::Advise() { if ( CanAdvise() ) { const wxDateTime now = wxDateTime::Now(); m_connection->Advise(m_connection->m_advise, now.Format()); const wxString s = now.FormatTime() + " " + now.FormatDate(); m_connection->Advise(m_connection->m_advise, s.mb_str(), wxNO_LEN); #if wxUSE_DDE_FOR_IPC wxLogMessage("DDE Advise type argument cannot be wxIPC_PRIVATE. " "The client will receive it as wxIPC_TEXT, " " and receive the correct no of bytes, " "but not print a correct log entry."); #endif char bytes[3] = { '1', '2', '3' }; m_connection->Advise(m_connection->m_advise, bytes, 3, wxIPC_PRIVATE); } }
void MyServer::Advise() { if ( CanAdvise() ) { const wxDateTime now = wxDateTime::Now(); wxString str = wxString::FromUTF8("\xd0\x9f\xd1\x80\xd0\xb8\xd0\xb2\xd0\xb5\xd1\x82"); m_connection->Advise(m_connection->m_advise, str + " (using UTF-8)"); str += " (using wchar_t)"; m_connection->Advise(m_connection->m_advise, str.wc_str(), (str.length() + 1)*sizeof(wchar_t), wxIPC_UNICODETEXT); // This one uses wxIPC_TEXT by default. const wxString s = now.FormatTime() + " " + now.FormatDate(); m_connection->Advise(m_connection->m_advise, s.mb_str(), wxNO_LEN); char bytes[3] = { '1', '2', '3' }; m_connection->Advise(m_connection->m_advise, bytes, 3, wxIPC_PRIVATE); } }
BOOL CDDEServer::DoCallback(WORD wType, WORD wFmt, HCONV hConv, HSZ hszTopic, HSZ hszItem, HDDEDATA hData, HDDEDATA *phReturnData) { // // See if we know the topic // CString strTopic = StringFromHsz(hszTopic); // // See if this is an execute request // if (wType == XTYP_EXECUTE) { // // Call the exec function to process it // Status(_T("Exec")); DWORD dwLength = 0; void* pData = ::DdeAccessData(hData, &dwLength); BOOL b = Exec(strTopic, pData, dwLength); ::DdeUnaccessData(hData); if (b) { *phReturnData = (HDDEDATA) DDE_FACK; return TRUE; // MH - Say we processed it } // // Either no handler or it didn't get handled by the function // Status(_T("Exec failed")); *phReturnData = (HDDEDATA) DDE_FNOTPROCESSED; return FALSE; } // // See if this is a connect request. Accept it if it is. // if (wType == XTYP_CONNECT) { if (!FindTopic(strTopic)) return FALSE; // unknown topic *phReturnData = (HDDEDATA) TRUE; return TRUE; } // // For any other transaction we need to be sure this is an // item we support and in some cases, that the format requested // is supported for that item. // CString strItem = StringFromHsz(hszItem); // // Now just do whatever is required for each specific transaction // BOOL b = FALSE; DWORD dwLength = 0; void* pData = NULL; switch (wType) { case XTYP_ADVSTART: // // Confirm that the supported topic/item pair is OK and // that the format is supported if (!CanAdvise(wFmt, strTopic, strItem)) { Status(_T("Can't advise on %s|%s"), (const TCHAR*)strTopic, (const TCHAR*)strItem); return FALSE; } // // Start an advise request. Topic/item and format are ok. // *phReturnData = (HDDEDATA) TRUE; break; case XTYP_POKE: // // Some data for one of our items. // pData = ::DdeAccessData(hData, &dwLength); b = Poke(wFmt, strTopic, strItem, pData, dwLength); ::DdeUnaccessData(hData); if (!b) { // // Nobody took the data. // Maybe its not a supported item or format // Status(_T("Poke %s|%s failed"), (const TCHAR*)strTopic, (const TCHAR*)strItem); return FALSE; } // // Data at the server has changed. See if we // did this ourself (from a poke) or if it's from // someone else. If it came from elsewhere then post // an advise notice of the change. // CONVINFO ci; ci.cb = sizeof(CONVINFO); if (::DdeQueryConvInfo(hConv, (DWORD)QID_SYNC, &ci)) { if (! (ci.wStatus & ST_ISSELF)) { // // It didn't come from us // ::DdePostAdvise(m_dwDDEInstance, hszTopic, hszItem); } } *phReturnData = (HDDEDATA) DDE_FACK; // say we took it break; case XTYP_ADVDATA: // // A server topic/item has changed value // pData = ::DdeAccessData(hData, &dwLength); b = AdviseData(wFmt, hConv, strTopic, strItem, pData, dwLength); ::DdeUnaccessData(hData); if (!b) { // // Nobody took the data. // Maybe its not of interrest // Status(_T("AdviseData %s|%s failed"), (const TCHAR*)strTopic, (const TCHAR*)strItem); *phReturnData = (HDDEDATA) DDE_FNOTPROCESSED; } else { *phReturnData = (HDDEDATA) DDE_FACK; // say we took it } break; case XTYP_ADVREQ: case XTYP_REQUEST: // // Attempt to start an advise or get the data on a topic/item // See if we have a request function for this item or // a generic one for the topic // { // scope for locals. CDDEAllocator allocr(m_dwDDEInstance, hszItem, wFmt, phReturnData); Status(_T("Request %s|%s"), (const TCHAR*)strTopic, (const TCHAR*)strItem); dwLength = 0; if (!Request(wFmt, strTopic, strItem, allocr)) { // // Nobody accepted the request // Maybe unsupported topic/item or bad format // Status(_T("Request %s|%s failed"), (LPCTSTR)strTopic, (LPCTSTR)strItem); *phReturnData = NULL; return FALSE; } } // end locals scope // Data already setup via 'allocr' param, so we are done. break; default: break; } // // Say we processed the transaction in some way // return TRUE; }