X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/77ffb5937e89927b621128789401db8921fe580f..b9efe021b554fa3967d1442cf758435c5cd5ae8f:/src/msw/dde.cpp?ds=sidebyside diff --git a/src/msw/dde.cpp b/src/msw/dde.cpp index 11641aeb8b..475b580110 100644 --- a/src/msw/dde.cpp +++ b/src/msw/dde.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -39,34 +39,13 @@ #include "wx/dde.h" #include "wx/intl.h" #include "wx/hashmap.h" +#include "wx/math.h" #include "wx/msw/private.h" #include #include -#ifdef __GNUWIN32_OLD__ - #include "wx/msw/gnuwin32/extra.h" -#endif - -// some compilers headers don't define this one (mingw32) -#ifndef DMLERR_NO_ERROR - #define DMLERR_NO_ERROR (0) - - // this one is also missing from some mingw32 headers, but there is no way - // to test for it (I know of) - the test for DMLERR_NO_ERROR works for me, - // but is surely not the right thing to do - extern "C" - HDDEDATA STDCALL DdeClientTransaction(LPBYTE pData, - DWORD cbData, - HCONV hConv, - HSZ hszItem, - UINT wFmt, - UINT wType, - DWORD dwTimeout, - LPDWORD pdwResult); -#endif // no DMLERR_NO_ERROR - // ---------------------------------------------------------------------------- // macros and constants // ---------------------------------------------------------------------------- @@ -326,7 +305,7 @@ bool wxDDEServer::Create(const wxString& server) wxDDEServer::~wxDDEServer() { - if ( !!m_serviceName ) + if ( !m_serviceName.IsEmpty() ) { HSZ hsz = DDEAtomFromString(m_serviceName); @@ -579,7 +558,8 @@ bool wxDDEConnection::Execute(const wxChar *data, int size, wxIPCFormat format) size = wxStrlen(data) + 1; } - bool ok = DdeClientTransaction((LPBYTE)data, size, + bool ok = DdeClientTransaction((LPBYTE)data, + size * sizeof(wxChar), GetHConv(), NULL, format, @@ -615,6 +595,7 @@ wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat fo } DWORD len = DdeGetData(returned_data, NULL, 0, 0); + len = (DWORD)ceil( double(len)/sizeof(wxChar) ); wxChar *data = GetBufferAtLeast( len ); wxASSERT_MSG(data != NULL, @@ -624,7 +605,7 @@ wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat fo (void) DdeFreeDataHandle(returned_data); if (size) - *size = (int)len; + *size = len; return data; } @@ -638,7 +619,8 @@ bool wxDDEConnection::Poke(const wxString& item, wxChar *data, int size, wxIPCFo } HSZ item_atom = DDEGetAtom(item); - bool ok = DdeClientTransaction((LPBYTE)data, size, + bool ok = DdeClientTransaction((LPBYTE)data, + size * sizeof(wxChar), GetHConv(), item_atom, format, XTYP_POKE, @@ -795,6 +777,7 @@ _DDECallback(WORD wType, if (connection) { DWORD len = DdeGetData(hData, NULL, 0, 0); + len = (DWORD)ceil( double(len)/sizeof(wxChar) ); wxChar *data = connection->GetBufferAtLeast( len ); wxASSERT_MSG(data != NULL, @@ -836,7 +819,7 @@ _DDECallback(WORD wType, HDDEDATA handle = DdeCreateDataHandle(DDEIdInst, (LPBYTE)data, - user_size, + user_size*sizeof(wxChar), 0, hsz2, wFmt, @@ -856,6 +839,7 @@ _DDECallback(WORD wType, wxString item_name = DDEStringFromAtom(hsz2); DWORD len = DdeGetData(hData, NULL, 0, 0); + len = (DWORD)ceil( double(len) / sizeof(wxChar) ); wxChar *data = connection->GetBufferAtLeast( len ); wxASSERT_MSG(data != NULL, @@ -919,7 +903,7 @@ _DDECallback(WORD wType, ( DDEIdInst, (LPBYTE)connection->m_sendingData, - connection->m_dataSize, + connection->m_dataSize*sizeof(wxChar), 0, hsz2, connection->m_dataType, @@ -943,6 +927,7 @@ _DDECallback(WORD wType, wxString item_name = DDEStringFromAtom(hsz2); DWORD len = DdeGetData(hData, NULL, 0, 0); + len = (DWORD)ceil( double(len) / sizeof(wxChar) ); wxChar *data = connection->GetBufferAtLeast( len ); wxASSERT_MSG(data != NULL,