+void wxMDIParentFrame::RemoveMDIChild(wxMDIChildFrame * WXUNUSED(child))
+{
+ switch ( GetChildFramesCount() )
+ {
+ case 1:
+ // last MDI child is being removed, remove the now unnecessary
+ // window menu too
+ RemoveWindowMenu();
+
+ // there is no need to call UpdateWindowMenu(true) here so this is
+ // not quite symmetric to AddMDIChild() above
+ break;
+
+ case 2:
+ // only one MDI child is going to remain, disable the menu commands
+ // which don't make sense for a single child window
+ UpdateWindowMenu(false);
+ break;
+ }
+}
+
+// ----------------------------------------------------------------------------
+// wxMDIParentFrame window menu handling
+// ----------------------------------------------------------------------------
+
+void wxMDIParentFrame::AddWindowMenu()
+{
+ if ( m_windowMenu )
+ MDIInsertWindowMenu(GetClientWindow(), m_hMenu, GetMDIWindowMenu(this));
+}
+
+void wxMDIParentFrame::RemoveWindowMenu()
+{
+ if ( m_windowMenu )
+ MDIRemoveWindowMenu(GetClientWindow(), m_hMenu);
+}
+
+void wxMDIParentFrame::UpdateWindowMenu(bool enable)
+{
+ if ( m_windowMenu )
+ {
+ m_windowMenu->Enable(wxID_MDI_WINDOW_NEXT, enable);
+ m_windowMenu->Enable(wxID_MDI_WINDOW_PREV, enable);
+ }
+}
+
+#if wxUSE_MENUS_NATIVE
+
+void wxMDIParentFrame::InternalSetMenuBar()
+{
+ if ( GetActiveChild() )
+ {
+ AddWindowMenu();
+ }
+ else // we don't have any MDI children yet
+ {
+ // wait until we do to add the window menu but do set the main menu for
+ // now (this is done by AddWindowMenu() as a side effect)
+ MDISetMenu(GetClientWindow(), (HMENU)m_hMenu, NULL);
+ }
+}
+
+#endif // wxUSE_MENUS_NATIVE
+