use private window class for dialup manager hidden window, otherwise wxWindowClass couldn't be unregistered because the wxDialUpManager-created window of this class was still alive
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34822 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
|
|
||||||
#include "wx/dynlib.h"
|
#include "wx/dynlib.h"
|
||||||
#include "wx/dialup.h"
|
#include "wx/dialup.h"
|
||||||
|
#include "wx/module.h"
|
||||||
|
|
||||||
DEFINE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED)
|
DEFINE_EVENT_TYPE(wxEVT_DIALUP_CONNECTED)
|
||||||
DEFINE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED)
|
DEFINE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED)
|
||||||
@@ -63,6 +64,14 @@ DEFINE_EVENT_TYPE(wxEVT_DIALUP_DISCONNECTED)
|
|||||||
#define INTERNET_CONNECTION_PROXY 4
|
#define INTERNET_CONNECTION_PROXY 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// implemented in utils.cpp
|
||||||
|
extern "C" WXDLLIMPEXP_BASE HWND
|
||||||
|
wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc);
|
||||||
|
|
||||||
|
static const wxChar *
|
||||||
|
wxMSWDIALUP_WNDCLASSNAME = wxT("_wxDialUpManager_Internal_Class");
|
||||||
|
static const wxChar *gs_classForDialUpWindow = NULL;
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -195,6 +204,7 @@ public:
|
|||||||
|
|
||||||
// for wxRasDialFunc
|
// for wxRasDialFunc
|
||||||
static HWND GetRasWindow() { return ms_hwndRas; }
|
static HWND GetRasWindow() { return ms_hwndRas; }
|
||||||
|
static void ResetRasWindow() { ms_hwndRas = NULL; }
|
||||||
static wxDialUpManagerMSW *GetDialer() { return ms_dialer; }
|
static wxDialUpManagerMSW *GetDialer() { return ms_dialer; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -280,6 +290,33 @@ private:
|
|||||||
DECLARE_NO_COPY_CLASS(wxDialUpManagerMSW)
|
DECLARE_NO_COPY_CLASS(wxDialUpManagerMSW)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// module to destroy helper window created by wxDialUpManagerMSW
|
||||||
|
class wxDialUpManagerModule : public wxModule
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool OnInit() { return true; }
|
||||||
|
void OnExit()
|
||||||
|
{
|
||||||
|
HWND hwnd = wxDialUpManagerMSW::GetRasWindow();
|
||||||
|
if ( hwnd )
|
||||||
|
{
|
||||||
|
::DestroyWindow(hwnd);
|
||||||
|
wxDialUpManagerMSW::ResetRasWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( gs_classForDialUpWindow )
|
||||||
|
{
|
||||||
|
::UnregisterClass(wxMSWDIALUP_WNDCLASSNAME, wxGetInstance());
|
||||||
|
gs_classForDialUpWindow = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxDialUpManagerModule)
|
||||||
|
};
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxDialUpManagerModule, wxModule)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private functions
|
// private functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1067,11 +1104,12 @@ bool wxDialUpManagerMSW::EnableAutoCheckOnlineStatus(size_t nSeconds)
|
|||||||
{
|
{
|
||||||
// create a hidden window to receive notification about connections
|
// create a hidden window to receive notification about connections
|
||||||
// status change
|
// status change
|
||||||
extern const wxChar *wxCanvasClassName;
|
ms_hwndRas = wxCreateHiddenWindow
|
||||||
ms_hwndRas = ::CreateWindow(wxCanvasClassName, NULL,
|
(
|
||||||
0, 0, 0, 0,
|
&gs_classForDialUpWindow,
|
||||||
0, NULL,
|
wxMSWDIALUP_WNDCLASSNAME,
|
||||||
(HMENU)NULL, wxGetInstance(), 0);
|
wxRasStatusWindowProc
|
||||||
|
);
|
||||||
if ( !ms_hwndRas )
|
if ( !ms_hwndRas )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("CreateWindow(RasHiddenWindow)"));
|
wxLogLastError(wxT("CreateWindow(RasHiddenWindow)"));
|
||||||
@@ -1080,9 +1118,6 @@ bool wxDialUpManagerMSW::EnableAutoCheckOnlineStatus(size_t nSeconds)
|
|||||||
|
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// and subclass it
|
|
||||||
wxSetWindowProc(ms_hwndRas, wxRasStatusWindowProc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_data->hWnd = ms_hwndRas;
|
m_data->hWnd = ms_hwndRas;
|
||||||
|
Reference in New Issue
Block a user