1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxMenu, wxMenuBar, wxMenuItem
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "menu.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
42 #include "wx/ownerdrw.h"
45 #include "wx/msw/private.h"
55 #ifndef TBSTYLE_NO_DROPDOWN_ARROW
56 #define TBSTYLE_NO_DROPDOWN_ARROW 0x0080
61 // other standard headers
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 extern wxMenu
*wxCurrentPopupMenu
;
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 // the (popup) menu title has this special id
75 static const int idMenuTitle
= -2;
77 // ----------------------------------------------------------------------------
79 // ----------------------------------------------------------------------------
81 // make the given menu item default
82 static void SetDefaultMenuItem(HMENU hmenu
, UINT id
)
87 mii
.cbSize
= sizeof(MENUITEMINFO
);
88 mii
.fMask
= MIIM_STATE
;
89 mii
.fState
= MFS_DEFAULT
;
91 if ( !::SetMenuItemInfo(hmenu
, id
, FALSE
, &mii
) )
93 wxLogLastError(wxT("SetMenuItemInfo"));
99 UINT
GetMenuState(HMENU hMenu
, UINT id
, UINT flags
)
103 info
.cbSize
= sizeof(info
);
104 info
.fMask
= MIIM_STATE
;
105 if ( !GetMenuItemInfo(hMenu
, id
, flags
& MF_BYCOMMAND
? FALSE
: TRUE
, & info
) )
106 wxLogLastError(wxT("GetMenuItemInfo"));
111 // ============================================================================
113 // ============================================================================
115 IMPLEMENT_DYNAMIC_CLASS(wxMenu
, wxEvtHandler
)
116 IMPLEMENT_DYNAMIC_CLASS(wxMenuBar
, wxWindow
)
135 // ---------------------------------------------------------------------------
136 // wxMenu construction, adding and removing menu items
137 // ---------------------------------------------------------------------------
139 // Construct a menu with optional title (then use append)
143 m_startRadioGroup
= -1;
146 m_hMenu
= (WXHMENU
)CreatePopupMenu();
149 wxLogLastError(wxT("CreatePopupMenu"));
152 // if we have a title, insert it in the beginning of the menu
155 Append(idMenuTitle
, m_title
);
160 // The wxWindow destructor will take care of deleting the submenus.
163 // we should free Windows resources only if Windows doesn't do it for us
164 // which happens if we're attached to a menubar or a submenu of another
166 if ( !IsAttached() && !GetParent() )
168 if ( !::DestroyMenu(GetHmenu()) )
170 wxLogLastError(wxT("DestroyMenu"));
176 WX_CLEAR_ARRAY(m_accels
);
177 #endif // wxUSE_ACCEL
182 // this will take effect during the next call to Append()
186 void wxMenu::Attach(wxMenuBarBase
*menubar
)
188 wxMenuBase::Attach(menubar
);
195 int wxMenu::FindAccel(int id
) const
197 size_t n
, count
= m_accels
.GetCount();
198 for ( n
= 0; n
< count
; n
++ )
200 if ( m_accels
[n
]->m_command
== id
)
207 void wxMenu::UpdateAccel(wxMenuItem
*item
)
209 if ( item
->IsSubMenu() )
211 wxMenu
*submenu
= item
->GetSubMenu();
212 wxMenuItemList::compatibility_iterator node
= submenu
->GetMenuItems().GetFirst();
215 UpdateAccel(node
->GetData());
217 node
= node
->GetNext();
220 else if ( !item
->IsSeparator() )
222 // find the (new) accel for this item
223 wxAcceleratorEntry
*accel
= wxGetAccelFromString(item
->GetText());
225 accel
->m_command
= item
->GetId();
228 int n
= FindAccel(item
->GetId());
229 if ( n
== wxNOT_FOUND
)
231 // no old, add new if any
235 return; // skipping RebuildAccelTable() below
239 // replace old with new or just remove the old one if no new
244 m_accels
.RemoveAt(n
);
249 m_menuBar
->RebuildAccelTable();
252 //else: it is a separator, they can't have accels, nothing to do
255 #endif // wxUSE_ACCEL
257 // append a new item or submenu to the menu
258 bool wxMenu::DoInsertOrAppend(wxMenuItem
*pItem
, size_t pos
)
262 #endif // wxUSE_ACCEL
266 // if "Break" has just been called, insert a menu break before this item
267 // (and don't forget to reset the flag)
269 flags
|= MF_MENUBREAK
;
273 if ( pItem
->IsSeparator() ) {
274 flags
|= MF_SEPARATOR
;
277 // id is the numeric id for normal menu items and HMENU for submenus as
278 // required by ::AppendMenu() API
280 wxMenu
*submenu
= pItem
->GetSubMenu();
281 if ( submenu
!= NULL
) {
282 wxASSERT_MSG( submenu
->GetHMenu(), wxT("invalid submenu") );
284 submenu
->SetParent(this);
286 id
= (UINT
)submenu
->GetHMenu();
295 wxString strippedString
;
300 #if wxUSE_OWNER_DRAWN
301 if ( pItem
->IsOwnerDrawn() ) { // want to get {Measure|Draw}Item messages?
302 // item draws itself, pass pointer to it in data parameter
303 flags
|= MF_OWNERDRAW
;
304 pData
= (LPCTSTR
)pItem
;
309 // menu is just a normal string (passed in data parameter)
313 strippedString
= wxStripMenuCodes(pItem
->GetText());
314 pData
= (wxChar
*)strippedString
.c_str();
316 pData
= (wxChar
*)pItem
->GetText().c_str();
321 if ( pos
== (size_t)-1 )
323 ok
= ::AppendMenu(GetHmenu(), flags
, id
, pData
);
327 ok
= ::InsertMenu(GetHmenu(), pos
, flags
| MF_BYPOSITION
, id
, pData
);
332 wxLogLastError(wxT("Insert or AppendMenu"));
337 // if we just appended the title, highlight it
339 if ( (int)id
== idMenuTitle
)
341 // visually select the menu title
342 SetDefaultMenuItem(GetHmenu(), id
);
346 // if we're already attached to the menubar, we must update it
347 if ( IsAttached() && m_menuBar
->IsAttached() )
349 m_menuBar
->Refresh();
355 void wxMenu::EndRadioGroup()
357 // we're not inside a radio group any longer
358 m_startRadioGroup
= -1;
361 bool wxMenu::DoAppend(wxMenuItem
*item
)
363 wxCHECK_MSG( item
, FALSE
, _T("NULL item in wxMenu::DoAppend") );
367 if ( item
->GetKind() == wxITEM_RADIO
)
369 int count
= GetMenuItemCount();
371 if ( m_startRadioGroup
== -1 )
373 // start a new radio group
374 m_startRadioGroup
= count
;
376 // for now it has just one element
377 item
->SetAsRadioGroupStart();
378 item
->SetRadioGroupEnd(m_startRadioGroup
);
380 // ensure that we have a checked item in the radio group
383 else // extend the current radio group
385 // we need to update its end item
386 item
->SetRadioGroupStart(m_startRadioGroup
);
387 wxMenuItemList::compatibility_iterator node
= GetMenuItems().Item(m_startRadioGroup
);
391 node
->GetData()->SetRadioGroupEnd(count
);
395 wxFAIL_MSG( _T("where is the radio group start item?") );
399 else // not a radio item
404 if ( !wxMenuBase::DoAppend(item
) || !DoInsertOrAppend(item
) )
411 // check the item initially
418 bool wxMenu::DoInsert(size_t pos
, wxMenuItem
*item
)
420 return wxMenuBase::DoInsert(pos
, item
) && DoInsertOrAppend(item
, pos
);
423 wxMenuItem
*wxMenu::DoRemove(wxMenuItem
*item
)
425 // we need to find the items position in the child list
427 wxMenuItemList::compatibility_iterator node
= GetMenuItems().GetFirst();
428 for ( pos
= 0; node
; pos
++ )
430 if ( node
->GetData() == item
)
433 node
= node
->GetNext();
436 // DoRemove() (unlike Remove) can only be called for existing item!
437 wxCHECK_MSG( node
, NULL
, wxT("bug in wxMenu::Remove logic") );
440 // remove the corresponding accel from the accel table
441 int n
= FindAccel(item
->GetId());
442 if ( n
!= wxNOT_FOUND
)
446 m_accels
.RemoveAt(n
);
448 //else: this item doesn't have an accel, nothing to do
449 #endif // wxUSE_ACCEL
451 // remove the item from the menu
452 if ( !::RemoveMenu(GetHmenu(), (UINT
)pos
, MF_BYPOSITION
) )
454 wxLogLastError(wxT("RemoveMenu"));
457 if ( IsAttached() && m_menuBar
->IsAttached() )
459 // otherwise, the chane won't be visible
460 m_menuBar
->Refresh();
463 // and from internal data structures
464 return wxMenuBase::DoRemove(item
);
467 // ---------------------------------------------------------------------------
468 // accelerator helpers
469 // ---------------------------------------------------------------------------
473 // create the wxAcceleratorEntries for our accels and put them into provided
474 // array - return the number of accels we have
475 size_t wxMenu::CopyAccels(wxAcceleratorEntry
*accels
) const
477 size_t count
= GetAccelCount();
478 for ( size_t n
= 0; n
< count
; n
++ )
480 *accels
++ = *m_accels
[n
];
486 #endif // wxUSE_ACCEL
488 // ---------------------------------------------------------------------------
490 // ---------------------------------------------------------------------------
492 void wxMenu::SetTitle(const wxString
& label
)
494 bool hasNoTitle
= m_title
.IsEmpty();
497 HMENU hMenu
= GetHmenu();
501 if ( !label
.IsEmpty() )
503 if ( !::InsertMenu(hMenu
, 0u, MF_BYPOSITION
| MF_STRING
,
504 (unsigned)idMenuTitle
, m_title
) ||
505 !::InsertMenu(hMenu
, 1u, MF_BYPOSITION
, (unsigned)-1, NULL
) )
507 wxLogLastError(wxT("InsertMenu"));
513 if ( label
.IsEmpty() )
515 // remove the title and the separator after it
516 if ( !RemoveMenu(hMenu
, 0, MF_BYPOSITION
) ||
517 !RemoveMenu(hMenu
, 0, MF_BYPOSITION
) )
519 wxLogLastError(wxT("RemoveMenu"));
528 info
.cbSize
= sizeof(info
);
529 info
.fMask
= MIIM_TYPE
;
530 info
.fType
= MFT_STRING
;
531 info
.cch
= m_title
.Length();
532 info
.dwTypeData
= (LPTSTR
) m_title
.c_str();
533 if ( !SetMenuItemInfo(hMenu
, 0, TRUE
, & info
) )
535 wxLogLastError(wxT("SetMenuItemInfo"));
538 if ( !ModifyMenu(hMenu
, 0u,
539 MF_BYPOSITION
| MF_STRING
,
540 (unsigned)idMenuTitle
, m_title
) )
542 wxLogLastError(wxT("ModifyMenu"));
549 // put the title string in bold face
550 if ( !m_title
.IsEmpty() )
552 SetDefaultMenuItem(GetHmenu(), (UINT
)idMenuTitle
);
557 // ---------------------------------------------------------------------------
559 // ---------------------------------------------------------------------------
561 bool wxMenu::MSWCommand(WXUINT
WXUNUSED(param
), WXWORD id
)
563 // ignore commands from the menu title
565 // NB: VC++ generates wrong assembler for `if ( id != idMenuTitle )'!!
566 if ( id
!= (WXWORD
)idMenuTitle
)
568 // VZ: previosuly, the command int was set to id too which was quite
569 // useless anyhow (as it could be retrieved using GetId()) and
570 // uncompatible with wxGTK, so now we use the command int instead
571 // to pass the checked status
572 UINT menuState
= ::GetMenuState(GetHmenu(), id
, MF_BYCOMMAND
) ;
573 SendEvent(id
, menuState
& MF_CHECKED
);
579 // ---------------------------------------------------------------------------
581 // ---------------------------------------------------------------------------
583 wxWindow
*wxMenu::GetWindow() const
585 if ( m_invokingWindow
!= NULL
)
586 return m_invokingWindow
;
587 else if ( m_menuBar
!= NULL
)
588 return m_menuBar
->GetFrame();
593 // ---------------------------------------------------------------------------
595 // ---------------------------------------------------------------------------
597 void wxMenuBar::Init()
599 m_eventHandler
= this;
606 wxMenuBar::wxMenuBar()
611 wxMenuBar::wxMenuBar( long WXUNUSED(style
) )
616 wxMenuBar::wxMenuBar(int count
, wxMenu
*menus
[], const wxString titles
[])
620 m_titles
.Alloc(count
);
622 for ( int i
= 0; i
< count
; i
++ )
624 m_menus
.Append(menus
[i
]);
625 m_titles
.Add(titles
[i
]);
627 menus
[i
]->Attach(this);
631 wxMenuBar::~wxMenuBar()
633 // In Windows CE, the menubar is always associated
634 // with a toolbar, which destroys the menu implicitly.
637 GetToolBar()->SetMenuBar(NULL
);
639 // we should free Windows resources only if Windows doesn't do it for us
640 // which happens if we're attached to a frame
641 if (m_hMenu
&& !IsAttached())
643 ::DestroyMenu((HMENU
)m_hMenu
);
644 m_hMenu
= (WXHMENU
)NULL
;
649 // ---------------------------------------------------------------------------
651 // ---------------------------------------------------------------------------
653 void wxMenuBar::Refresh()
655 wxCHECK_RET( IsAttached(), wxT("can't refresh unattached menubar") );
660 CommandBar_DrawMenuBar((HWND
) GetToolBar()->GetHWND(), 0);
663 DrawMenuBar(GetHwndOf(GetFrame()));
667 WXHMENU
wxMenuBar::Create()
669 // Note: this totally doesn't work on Smartphone,
670 // since you have to use resources.
671 // We'll have to find another way to add a menu
672 // by changing/adding menu items to an existing menu.
680 HWND hCommandBar
= (HWND
) GetToolBar()->GetHWND();
681 HMENU hMenu
= (HMENU
)::SendMessage(hCommandBar
, SHCMBM_GETMENU
, (WPARAM
)0, (LPARAM
)0);
685 memset(&tbButton
, 0, sizeof(TBBUTTON
));
686 tbButton
.iBitmap
= I_IMAGENONE
;
687 tbButton
.fsState
= TBSTATE_ENABLED
;
688 tbButton
.fsStyle
= TBSTYLE_DROPDOWN
| TBSTYLE_NO_DROPDOWN_ARROW
| TBSTYLE_AUTOSIZE
;
691 for (i
= 0; i
< GetMenuCount(); i
++)
693 HMENU hPopupMenu
= (HMENU
) GetMenu(i
)->GetHMenu() ;
694 tbButton
.dwData
= (DWORD
)hPopupMenu
;
695 wxString label
= wxStripMenuCodes(GetLabelTop(i
));
696 tbButton
.iString
= (int) label
.c_str();
700 tbButton
.idCommand
= NewControlId();
701 if (!::SendMessage(hCommandBar
, TB_INSERTBUTTON
, position
, (LPARAM
)&tbButton
))
703 wxLogLastError(wxT("TB_INSERTBUTTON"));
707 m_hMenu
= (WXHMENU
) hMenu
;
713 m_hMenu
= (WXHMENU
)::CreateMenu();
717 wxLogLastError(wxT("CreateMenu"));
721 size_t count
= GetMenuCount(), i
;
722 wxMenuList::iterator it
;
723 for ( i
= 0, it
= m_menus
.begin(); i
< count
; i
++, it
++ )
725 if ( !::AppendMenu((HMENU
)m_hMenu
, MF_POPUP
| MF_STRING
,
726 (UINT
)(*it
)->GetHMenu(),
729 wxLogLastError(wxT("AppendMenu"));
738 // ---------------------------------------------------------------------------
739 // wxMenuBar functions to work with the top level submenus
740 // ---------------------------------------------------------------------------
742 // NB: we don't support owner drawn top level items for now, if we do these
743 // functions would have to be changed to use wxMenuItem as well
745 void wxMenuBar::EnableTop(size_t pos
, bool enable
)
747 wxCHECK_RET( IsAttached(), wxT("doesn't work with unattached menubars") );
749 int flag
= enable
? MF_ENABLED
: MF_GRAYED
;
751 EnableMenuItem((HMENU
)m_hMenu
, pos
, MF_BYPOSITION
| flag
);
756 void wxMenuBar::SetLabelTop(size_t pos
, const wxString
& label
)
758 wxCHECK_RET( pos
< GetMenuCount(), wxT("invalid menu index") );
760 m_titles
[pos
] = label
;
766 //else: have to modify the existing menu
769 UINT flagsOld
= ::GetMenuState((HMENU
)m_hMenu
, pos
, MF_BYPOSITION
);
770 if ( flagsOld
== 0xFFFFFFFF )
772 wxLogLastError(wxT("GetMenuState"));
777 if ( flagsOld
& MF_POPUP
)
779 // HIBYTE contains the number of items in the submenu in this case
781 id
= (UINT
)::GetSubMenu((HMENU
)m_hMenu
, pos
);
791 info
.cbSize
= sizeof(info
);
792 info
.fMask
= MIIM_TYPE
;
793 info
.fType
= MFT_STRING
;
794 info
.cch
= label
.Length();
795 info
.dwTypeData
= (LPTSTR
) label
.c_str();
796 if ( !SetMenuItemInfo(GetHmenu(), id
, TRUE
, & info
) )
798 wxLogLastError(wxT("SetMenuItemInfo"));
802 if ( ::ModifyMenu(GetHmenu(), pos
, MF_BYPOSITION
| MF_STRING
| flagsOld
,
803 id
, label
) == (int)0xFFFFFFFF )
805 wxLogLastError(wxT("ModifyMenu"));
812 wxString
wxMenuBar::GetLabelTop(size_t pos
) const
814 wxCHECK_MSG( pos
< GetMenuCount(), wxEmptyString
,
815 wxT("invalid menu index in wxMenuBar::GetLabelTop") );
817 return m_titles
[pos
];
820 // ---------------------------------------------------------------------------
821 // wxMenuBar construction
822 // ---------------------------------------------------------------------------
824 wxMenu
*wxMenuBar::Replace(size_t pos
, wxMenu
*menu
, const wxString
& title
)
826 wxMenu
*menuOld
= wxMenuBarBase::Replace(pos
, menu
, title
);
830 m_titles
[pos
] = title
;
834 // can't use ModifyMenu() because it deletes the submenu it replaces
835 if ( !::RemoveMenu(GetHmenu(), (UINT
)pos
, MF_BYPOSITION
) )
837 wxLogLastError(wxT("RemoveMenu"));
840 if ( !::InsertMenu(GetHmenu(), (UINT
)pos
,
841 MF_BYPOSITION
| MF_POPUP
| MF_STRING
,
842 (UINT
)GetHmenuOf(menu
), title
) )
844 wxLogLastError(wxT("InsertMenu"));
848 if ( menuOld
->HasAccels() || menu
->HasAccels() )
850 // need to rebuild accell table
853 #endif // wxUSE_ACCEL
861 bool wxMenuBar::Insert(size_t pos
, wxMenu
*menu
, const wxString
& title
)
863 if ( !wxMenuBarBase::Insert(pos
, menu
, title
) )
866 m_titles
.Insert(title
, pos
);
874 memset(&tbButton
, 0, sizeof(TBBUTTON
));
875 tbButton
.iBitmap
= I_IMAGENONE
;
876 tbButton
.fsState
= TBSTATE_ENABLED
;
877 tbButton
.fsStyle
= TBSTYLE_DROPDOWN
| TBSTYLE_NO_DROPDOWN_ARROW
| TBSTYLE_AUTOSIZE
;
879 HMENU hPopupMenu
= (HMENU
) menu
->GetHMenu() ;
880 tbButton
.dwData
= (DWORD
)hPopupMenu
;
881 wxString label
= wxStripMenuCodes(title
);
882 tbButton
.iString
= (int) label
.c_str();
884 tbButton
.idCommand
= NewControlId();
885 if (!::SendMessage((HWND
) GetToolBar()->GetHWND(), TB_INSERTBUTTON
, pos
, (LPARAM
)&tbButton
))
887 wxLogLastError(wxT("TB_INSERTBUTTON"));
891 if ( !::InsertMenu(GetHmenu(), pos
,
892 MF_BYPOSITION
| MF_POPUP
| MF_STRING
,
893 (UINT
)GetHmenuOf(menu
), title
) )
895 wxLogLastError(wxT("InsertMenu"));
899 if ( menu
->HasAccels() )
901 // need to rebuild accell table
904 #endif // wxUSE_ACCEL
912 bool wxMenuBar::Append(wxMenu
*menu
, const wxString
& title
)
914 WXHMENU submenu
= menu
? menu
->GetHMenu() : 0;
915 wxCHECK_MSG( submenu
, FALSE
, wxT("can't append invalid menu to menubar") );
917 if ( !wxMenuBarBase::Append(menu
, title
) )
928 memset(&tbButton
, 0, sizeof(TBBUTTON
));
929 tbButton
.iBitmap
= I_IMAGENONE
;
930 tbButton
.fsState
= TBSTATE_ENABLED
;
931 tbButton
.fsStyle
= TBSTYLE_DROPDOWN
| TBSTYLE_NO_DROPDOWN_ARROW
| TBSTYLE_AUTOSIZE
;
933 size_t pos
= GetMenuCount();
934 HMENU hPopupMenu
= (HMENU
) menu
->GetHMenu() ;
935 tbButton
.dwData
= (DWORD
)hPopupMenu
;
936 wxString label
= wxStripMenuCodes(title
);
937 tbButton
.iString
= (int) label
.c_str();
939 tbButton
.idCommand
= NewControlId();
940 if (!::SendMessage((HWND
) GetToolBar()->GetHWND(), TB_INSERTBUTTON
, pos
, (LPARAM
)&tbButton
))
942 wxLogLastError(wxT("TB_INSERTBUTTON"));
946 if ( !::AppendMenu(GetHmenu(), MF_POPUP
| MF_STRING
,
947 (UINT
)submenu
, title
) )
949 wxLogLastError(wxT("AppendMenu"));
954 if ( menu
->HasAccels() )
956 // need to rebuild accelerator table
959 #endif // wxUSE_ACCEL
967 wxMenu
*wxMenuBar::Remove(size_t pos
)
969 wxMenu
*menu
= wxMenuBarBase::Remove(pos
);
978 if (!::SendMessage((HWND
) GetToolBar()->GetHWND(), TB_DELETEBUTTON
, (UINT
) pos
, (LPARAM
) 0))
980 wxLogLastError(wxT("TB_DELETEBUTTON"));
984 if ( !::RemoveMenu(GetHmenu(), (UINT
)pos
, MF_BYPOSITION
) )
986 wxLogLastError(wxT("RemoveMenu"));
990 if ( menu
->HasAccels() )
992 // need to rebuild accell table
995 #endif // wxUSE_ACCEL
1000 m_titles
.RemoveAt(pos
);
1007 void wxMenuBar::RebuildAccelTable()
1009 // merge the accelerators of all menus into one accel table
1010 size_t nAccelCount
= 0;
1011 size_t i
, count
= GetMenuCount();
1012 wxMenuList::iterator it
;
1013 for ( i
= 0, it
= m_menus
.begin(); i
< count
; i
++, it
++ )
1015 nAccelCount
+= (*it
)->GetAccelCount();
1020 wxAcceleratorEntry
*accelEntries
= new wxAcceleratorEntry
[nAccelCount
];
1023 for ( i
= 0, it
= m_menus
.begin(); i
< count
; i
++, it
++ )
1025 nAccelCount
+= (*it
)->CopyAccels(&accelEntries
[nAccelCount
]);
1028 m_accelTable
= wxAcceleratorTable(nAccelCount
, accelEntries
);
1030 delete [] accelEntries
;
1034 #endif // wxUSE_ACCEL
1036 void wxMenuBar::Attach(wxFrame
*frame
)
1038 wxMenuBarBase::Attach(frame
);
1041 RebuildAccelTable();
1042 #endif // wxUSE_ACCEL
1045 void wxMenuBar::Detach()
1047 wxMenuBarBase::Detach();
1050 #endif // wxUSE_MENUS