#include "wx/app.h"
#endif
-#include "wx/msw/private.h"
+#include "wx/module.h"
#include "wx/dde.h"
+#include "wx/msw/private.h"
+#include <windows.h>
+#include <ddeml.h>
+
+#ifndef __TWIN32__
#ifdef __GNUWIN32__
#include "wx/msw/gnuwin32/extra.h"
#endif
+#endif
-#include <windows.h>
-#include <ddeml.h>
#include <string.h>
#ifdef __WIN32__
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)
{
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;
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();
m_connections.Append(connection);
return connection;
}
- else return NULL;
+ else return (wxConnectionBase*) NULL;
}
}
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