]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dde.cpp
Hopefully fixed library names generated by wx-config for OS/2's PM port.
[wxWidgets.git] / src / msw / dde.cpp
index 6554c530debad9e0d4e76e18a56404fb72b4193e..475b580110dac8ae0b8ffcdb48beaa67d649bd42 100644 (file)
 #include "wx/dde.h"
 #include "wx/intl.h"
 #include "wx/hashmap.h"
+#include "wx/math.h"
 
 #include "wx/msw/private.h"
 
 #include <string.h>
 #include <ddeml.h>
 
-#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,