Clean up wxMSW tooltip window on library shutdown

Not doing this prevented the tooltips from working correctly if the library
was shut down and reinitialized again, so add a module ensuring this is done.

Closes #17360.
This commit is contained in:
Rebel_X 2016-02-13 12:55:17 +01:00 committed by Vadim Zeitlin
parent ccd361c98f
commit 35f35ea407
2 changed files with 39 additions and 0 deletions

View File

@ -74,6 +74,9 @@ public:
static void UpdateVisibility();
private:
// This module calls our DeleteToolTipCtrl().
friend class wxToolTipModule;
// Adds a window other than our main m_window to this tooltip.
void DoAddHWND(WXHWND hWnd);
@ -92,6 +95,9 @@ private:
// create the tooltip ctrl if it doesn't exist yet and return its HWND
static WXHWND GetToolTipCtrl();
// to be used in wxModule for deleting tooltip ctrl window when exiting mainloop
static void DeleteToolTipCtrl();
// new tooltip maximum width, defaults to min(display width, 400)
static int ms_maxWidth;

View File

@ -134,6 +134,30 @@ public:
}
};
// Takes care of deleting ToolTip control window when shutting down the library.
class wxToolTipModule : public wxModule
{
public:
wxToolTipModule()
{
}
virtual bool OnInit() wxOVERRIDE
{
return true;
}
virtual void OnExit() wxOVERRIDE
{
wxToolTip::DeleteToolTipCtrl();
}
private:
wxDECLARE_DYNAMIC_CLASS(wxToolTipModule);
};
wxIMPLEMENT_DYNAMIC_CLASS(wxToolTipModule, wxModule);
#ifdef __VISUALC__
#pragma warning( default : 4097 )
#endif
@ -253,6 +277,15 @@ void wxToolTip::SetMaxWidth(int width)
ms_maxWidth = width;
}
void wxToolTip::DeleteToolTipCtrl()
{
if ( ms_hwndTT )
{
::DestroyWindow((HWND)ms_hwndTT);
ms_hwndTT = (WXHWND)NULL;
}
}
// ---------------------------------------------------------------------------
// implementation helpers
// ---------------------------------------------------------------------------