Add wxMenu::MSWDetachHMENU().

Make it possible to pass ownership of a wxMenu to win32.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@76725 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2014-06-18 12:57:30 +00:00
parent 09c05de725
commit 5e45443568
2 changed files with 6 additions and 1 deletions

View File

@@ -67,6 +67,11 @@ public:
// menu handle and will delete it when this object is destroyed. // menu handle and will delete it when this object is destroyed.
static wxMenu *MSWNewFromHMENU(WXHMENU hMenu) { return new wxMenu(hMenu); } static wxMenu *MSWNewFromHMENU(WXHMENU hMenu) { return new wxMenu(hMenu); }
#if wxABI_VERSION >= 30002
// Detaches HMENU so that it isn't deleted when this object is destroyed.
// Don't use this object after calling this method.
WXHMENU MSWDetachHMENU() { WXHMENU m = m_hMenu; m_hMenu = NULL; return m; }
#endif
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------

View File

@@ -360,7 +360,7 @@ wxMenu::~wxMenu()
// we should free Windows resources only if Windows doesn't do it for us // we should free Windows resources only if Windows doesn't do it for us
// which happens if we're attached to a menubar or a submenu of another // which happens if we're attached to a menubar or a submenu of another
// menu // menu
if ( !IsAttached() && !GetParent() ) if ( m_hMenu && !IsAttached() && !GetParent() )
{ {
if ( !::DestroyMenu(GetHmenu()) ) if ( !::DestroyMenu(GetHmenu()) )
{ {