X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47d67540a017101b3e46abe9ef0f55914d8de37e..cb6827a8c645a883a2d2a7b117a50609d706ccce:/src/msw/dde.cpp diff --git a/src/msw/dde.cpp b/src/msw/dde.cpp index c46f04c233..d8fe4dfa5a 100644 --- a/src/msw/dde.cpp +++ b/src/msw/dde.cpp @@ -31,15 +31,19 @@ #include "wx/app.h" #endif -#include "wx/msw/private.h" +#include "wx/module.h" #include "wx/dde.h" +#include "wx/msw/private.h" +#include +#include + +#ifndef __TWIN32__ #ifdef __GNUWIN32__ #include "wx/msw/gnuwin32/extra.h" #endif +#endif -#include -#include #include #ifdef __WIN32__ @@ -118,6 +122,21 @@ void wxDDECleanUp() delete [] DDEDefaultIPCBuffer ; } +// A module to allow DDE initialization/cleanup +// without calling these functions from app.cpp or from +// the user's application. + +class wxDDEModule: public wxModule +{ +DECLARE_DYNAMIC_CLASS(wxDDEModule) +public: + wxDDEModule() {} + bool OnInit() { wxDDEInitialize(); return TRUE; }; + void OnExit() { wxDDECleanUp(); }; +}; + +IMPLEMENT_DYNAMIC_CLASS(wxDDEModule, wxModule) + // Global find connection static wxDDEConnection *DDEFindConnection(HCONV hConv) { @@ -197,7 +216,7 @@ bool wxDDEServer::Create(const wxString& server_name) m_serviceName = server_name; HSZ serviceName = DdeCreateStringHandle(DDEIdInst, (char*) (const char *)server_name, CP_WINANSI); - if (DdeNameService(DDEIdInst, serviceName, NULL, DNS_REGISTER) == 0) + if (DdeNameService(DDEIdInst, serviceName, (HSZ) NULL, DNS_REGISTER) == 0) { DDEPrintError(); return FALSE; @@ -309,8 +328,8 @@ wxConnectionBase *wxDDEClient::MakeConnection(const wxString& /* host */, const HSZ topic_atom = DdeCreateStringHandle(DDEIdInst, (char*) (const char *)topic, CP_WINANSI); HCONV hConv = DdeConnect(DDEIdInst, serviceName, topic_atom, (PCONVCONTEXT)NULL); - if (hConv == NULL) - return NULL; + if (hConv == (HCONV) NULL) + return (wxConnectionBase*) NULL; else { wxDDEConnection *connection = (wxDDEConnection*) OnMakeConnection(); @@ -322,7 +341,7 @@ wxConnectionBase *wxDDEClient::MakeConnection(const wxString& /* host */, const m_connections.Append(connection); return connection; } - else return NULL; + else return (wxConnectionBase*) NULL; } } @@ -420,7 +439,7 @@ bool wxDDEConnection::Disconnect(void) return (DdeDisconnect((HCONV) m_hConv) != 0); } -bool wxDDEConnection::Execute(char *data, int size, wxDataFormat format) +bool wxDDEConnection::Execute(char *data, int size, wxIPCFormat format) { DWORD result; if (size < 0) @@ -432,7 +451,7 @@ bool wxDDEConnection::Execute(char *data, int size, wxDataFormat format) NULL, format, XTYP_EXECUTE, 5000, &result) ? TRUE : FALSE); } -char *wxDDEConnection::Request(const wxString& item, int *size, wxDataFormat format) +char *wxDDEConnection::Request(const wxString& item, int *size, wxIPCFormat format) { DWORD result; HSZ atom = DDEGetAtom(item); @@ -452,7 +471,7 @@ char *wxDDEConnection::Request(const wxString& item, int *size, wxDataFormat for else return NULL; } -bool wxDDEConnection::Poke(const wxString& item, char *data, int size, wxDataFormat format) +bool wxDDEConnection::Poke(const wxString& item, char *data, int size, wxIPCFormat format) { DWORD result; if (size < 0) @@ -484,7 +503,7 @@ bool wxDDEConnection::StopAdvise(const wxString& item) } // Calls that SERVER can make -bool wxDDEConnection::Advise(const wxString& item, char *data, int size, wxDataFormat format) +bool wxDDEConnection::Advise(const wxString& item, char *data, int size, wxIPCFormat format) { if (size < 0) size = strlen(data); @@ -579,7 +598,7 @@ DWORD /* lData2 */) { DWORD len = DdeGetData(hData, (LPBYTE)(connection->m_bufPtr), connection->m_bufSize, 0); DdeFreeDataHandle(hData); - if (connection->OnExecute(connection->m_topicName, connection->m_bufPtr, (int)len, (wxDataFormat) wFmt)) + if (connection->OnExecute(connection->m_topicName, connection->m_bufPtr, (int)len, (wxIPCFormat) wFmt)) return (DDERETURN)DDE_FACK; else return (DDERETURN)DDE_FNOTPROCESSED; @@ -598,7 +617,7 @@ DWORD /* lData2 */) CP_WINANSI); int user_size = -1; - char *data = connection->OnRequest(connection->m_topicName, wxString(item_name), &user_size, (wxDataFormat) wFmt); + char *data = connection->OnRequest(connection->m_topicName, wxString(item_name), &user_size, (wxIPCFormat) wFmt); if (data) { if (user_size < 0) user_size = strlen(data); @@ -622,7 +641,7 @@ DWORD /* lData2 */) CP_WINANSI); DWORD len = DdeGetData(hData, (LPBYTE)(connection->m_bufPtr), connection->m_bufSize, 0); DdeFreeDataHandle(hData); - connection->OnPoke(connection->m_topicName, wxString(item_name), connection->m_bufPtr, (int)len, (wxDataFormat) wFmt); + connection->OnPoke(connection->m_topicName, wxString(item_name), connection->m_bufPtr, (int)len, (wxIPCFormat) wFmt); return (DDERETURN)DDE_FACK; } else return (DDERETURN)DDE_FNOTPROCESSED; break; @@ -684,7 +703,7 @@ DWORD /* lData2 */) DWORD len = DdeGetData(hData, (LPBYTE)(connection->m_bufPtr), connection->m_bufSize, 0); DdeFreeDataHandle(hData); - if (connection->OnAdvise(connection->m_topicName, wxString(item_name), connection->m_bufPtr, (int)len, (wxDataFormat) wFmt)) + if (connection->OnAdvise(connection->m_topicName, wxString(item_name), connection->m_bufPtr, (int)len, (wxIPCFormat) wFmt)) return (DDERETURN)DDE_FACK; else return (DDERETURN)DDE_FNOTPROCESSED; @@ -778,7 +797,7 @@ void DDEPrintError(void) err = "Unrecognised error type."; break; } - MessageBox(NULL, (LPCSTR)err, "DDE Error", MB_OK | MB_ICONINFORMATION); + MessageBox((HWND) NULL, (LPCSTR)err, "DDE Error", MB_OK | MB_ICONINFORMATION); } #endif