]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dde.cpp
Some change logs
[wxWidgets.git] / src / msw / dde.cpp
index 9fd53fd87d813b13fb447c9c15a3cacd88728b9a..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
-
 // ----------------------------------------------------------------------------
 // macros and constants
 // ----------------------------------------------------------------------------
@@ -308,7 +305,7 @@ bool wxDDEServer::Create(const wxString& server)
 
 wxDDEServer::~wxDDEServer()
 {
-    if ( !!m_serviceName )
+    if ( !m_serviceName.IsEmpty() )
     {
         HSZ hsz = DDEAtomFromString(m_serviceName);
 
@@ -561,7 +558,7 @@ bool wxDDEConnection::Execute(const wxChar *data, int size, wxIPCFormat format)
         size = wxStrlen(data) + 1;
     }
 
-    bool ok = DdeClientTransaction((LPBYTE)data, 
+    bool ok = DdeClientTransaction((LPBYTE)data,
                                     size * sizeof(wxChar),
                                     GetHConv(),
                                     NULL,
@@ -598,8 +595,9 @@ 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/sizeof(wxChar) );
+    wxChar *data = GetBufferAtLeast( len );
     wxASSERT_MSG(data != NULL,
                  _T("Buffer too small in wxDDEConnection::Request") );
     (void) DdeGetData(returned_data, (LPBYTE)data, len, 0);
@@ -607,7 +605,7 @@ wxChar *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat fo
     (void) DdeFreeDataHandle(returned_data);
 
     if (size)
-        *size = (int)len/sizeof(wxChar);
+        *size = len;
 
     return data;
 }
@@ -621,7 +619,7 @@ bool wxDDEConnection::Poke(const wxString& item, wxChar *data, int size, wxIPCFo
     }
 
     HSZ item_atom = DDEGetAtom(item);
-    bool ok = DdeClientTransaction((LPBYTE)data, 
+    bool ok = DdeClientTransaction((LPBYTE)data,
                                    size * sizeof(wxChar),
                                    GetHConv(),
                                    item_atom, format,
@@ -779,8 +777,9 @@ _DDECallback(WORD wType,
                 if (connection)
                 {
                     DWORD len = DdeGetData(hData, NULL, 0, 0);
+                    len = (DWORD)ceil( double(len)/sizeof(wxChar) );
 
-                    wxChar *data = connection->GetBufferAtLeast( len/sizeof(wxChar) );
+                    wxChar *data = connection->GetBufferAtLeast( len );
                     wxASSERT_MSG(data != NULL,
                                  _T("Buffer too small in _DDECallback (XTYP_EXECUTE)") );
 
@@ -790,7 +789,7 @@ _DDECallback(WORD wType,
 
                     if ( connection->OnExecute(connection->m_topicName,
                                                data,
-                                               (int)len/sizeof(wxChar),
+                                               (int)len,
                                                (wxIPCFormat) wFmt) )
                     {
                         return (DDERETURN)(DWORD)DDE_FACK;
@@ -840,8 +839,9 @@ _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/sizeof(wxChar) );
+                    wxChar *data = connection->GetBufferAtLeast( len );
                     wxASSERT_MSG(data != NULL,
                                  _T("Buffer too small in _DDECallback (XTYP_EXECUTE)") );
 
@@ -852,7 +852,7 @@ _DDECallback(WORD wType,
                     connection->OnPoke(connection->m_topicName,
                                        item_name,
                                        data,
-                                       (int)len/sizeof(wxChar),
+                                       (int)len,
                                        (wxIPCFormat) wFmt);
 
                     return (DDERETURN)DDE_FACK;
@@ -927,8 +927,9 @@ _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/sizeof(wxChar) );
+                    wxChar *data = connection->GetBufferAtLeast( len );
                     wxASSERT_MSG(data != NULL,
                                  _T("Buffer too small in _DDECallback (XTYP_ADVDATA)") );
 
@@ -938,7 +939,7 @@ _DDECallback(WORD wType,
                     if ( connection->OnAdvise(connection->m_topicName,
                                               item_name,
                                               data,
-                                              (int)len/sizeof(wxChar),
+                                              (int)len,
                                               (wxIPCFormat) wFmt) )
                     {
                         return (DDERETURN)(DWORD)DDE_FACK;