+wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
+{
+ HWND hWnd = (HWND)::SendMessage(GetWinHwnd(GetClientWindow()),
+ WM_MDIGETACTIVE, 0, 0L);
+ if ( !hWnd )
+ return NULL;
+
+ return static_cast<wxMDIChildFrame *>(wxFindWinFromHandle(hWnd));
+}
+
+int wxMDIParentFrame::GetChildFramesCount() const
+{
+ int count = 0;
+ for ( wxWindowList::const_iterator i = GetChildren().begin();
+ i != GetChildren().end();
+ ++i )
+ {
+ if ( wxDynamicCast(*i, wxMDIChildFrame) )
+ count++;
+ }
+
+ return count;
+}
+
+#if wxUSE_MENUS
+
+void wxMDIParentFrame::AddMDIChild(wxMDIChildFrame * WXUNUSED(child))
+{
+ switch ( GetChildFramesCount() )
+ {
+ case 1:
+ // first MDI child was just added, we need to insert the window
+ // menu now if we have it
+ AddWindowMenu();
+
+ // and disable the items which can't be used until we have more
+ // than one child
+ UpdateWindowMenu(false);
+ break;
+
+ case 2:
+ // second MDI child was added, enable the menu items which were
+ // disabled because they didn't make sense for a single window
+ UpdateWindowMenu(true);
+ break;
+ }
+}
+
+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()