#endif
#ifndef __GSOCKET_STANDALONE__
-#include "wx/defs.h"
-#include "wx/setup.h"
+# include "wx/platform.h"
+# include "wx/setup.h"
#endif
#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
#include "wx/msw/gsockmsw.h"
#include "wx/gsocket.h"
+HINSTANCE wxGetInstance(void);
#define INSTANCE wxGetInstance()
#else
#endif
#define CLASSNAME TEXT("_GSocket_Internal_Window_Class")
-#define WINDOWNAME TEXT("_GSocket_Internal_Window_Name")
+
+/* implemented in utils.cpp */
+extern WXDLLIMPEXP_BASE HWND
+wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc);
/* Maximum number of different GSocket objects at a given time.
* This value can be modified at will, but it CANNOT be greater
/* Global initializers */
-int GSocket_Init(void)
+int _GSocket_GUI_Init(void)
{
- WSADATA wsaData;
- WNDCLASS winClass;
+ static LPCTSTR pclassname = NULL;
int i;
/* Create internal window for event notifications */
- winClass.style = 0;
- winClass.lpfnWndProc = _GSocket_Internal_WinProc;
- winClass.cbClsExtra = 0;
- winClass.cbWndExtra = 0;
- winClass.hInstance = INSTANCE;
- winClass.hIcon = (HICON) NULL;
- winClass.hCursor = (HCURSOR) NULL;
- winClass.hbrBackground = (HBRUSH) NULL;
- winClass.lpszMenuName = (LPCTSTR) NULL;
- winClass.lpszClassName = CLASSNAME;
-
- RegisterClass(&winClass);
- hWin = CreateWindow(CLASSNAME,
- WINDOWNAME,
- 0, 0, 0, 0, 0,
- (HWND) NULL, (HMENU) NULL, INSTANCE, (LPVOID) NULL);
-
- if (!hWin) return FALSE;
+ hWin = wxCreateHiddenWindow(&pclassname, CLASSNAME, _GSocket_Internal_WinProc);
+ if (!hWin)
+ return FALSE;
/* Initialize socket list */
InitializeCriticalSection(&critical);
}
firstAvailable = 0;
- /* Initialize WinSocket */
- return (WSAStartup((1 << 8) | 1, &wsaData) == 0);
+ return TRUE;
}
-void GSocket_Cleanup(void)
+void _GSocket_GUI_Cleanup(void)
{
/* Destroy internal window */
DestroyWindow(hWin);
/* Delete critical section */
DeleteCriticalSection(&critical);
-
- /* Cleanup WinSocket */
- WSACleanup();
}
/* Per-socket GUI initialization / cleanup */
-int _GSocket_GUI_Init(GSocket *socket)
+int _GSocket_GUI_Init_Socket(GSocket *socket)
{
int i;
return TRUE;
}
-void _GSocket_GUI_Destroy(GSocket *socket)
+void _GSocket_GUI_Destroy_Socket(GSocket *socket)
{
/* Remove the socket from the list */
EnterCriticalSection(&critical);