From: boca4711 <boc...@us...> - 2004-11-21 14:06:17
|
Update of /cvsroot/anyedit/AnyEditToolkit/GuiLib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21094/GuiLib Modified Files: GuiMDIFrame.cpp GuiMDIFrame.h Log Message: Added call for more windows dialog Index: GuiMDIFrame.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditToolkit/GuiLib/GuiMDIFrame.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuiMDIFrame.cpp 11 Oct 2004 20:25:56 -0000 1.3 --- GuiMDIFrame.cpp 21 Nov 2004 14:04:41 -0000 1.4 *************** *** 22,30 **** ****************************************************************************/ - - #include "stdafx.h" #include "GuiMDIFrame.h" #include "GuiMiniFrame.h" #ifdef _DEBUG --- 22,29 ---- ****************************************************************************/ #include "stdafx.h" #include "GuiMDIFrame.h" #include "GuiMiniFrame.h" + #include "GuiMDIWindowsDlg.h" #ifdef _DEBUG *************** *** 34,37 **** --- 33,38 ---- #endif + #define DEFAULT_NUMBER_OF_MDIS 9 + ///////////////////////////////////////////////////////////////////////////// // CGuiMDIFrame *************** *** 56,62 **** BEGIN_MESSAGE_MAP(CGuiMDIFrame, CMDIFrameWnd) //{{AFX_MSG_MAP(CGuiMDIFrame) - // NOTE - the ClassWizard will add and remove mapping macros here. ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) ON_WM_SYSCOLORCHANGE() //}}AFX_MSG_MAP END_MESSAGE_MAP() --- 57,63 ---- BEGIN_MESSAGE_MAP(CGuiMDIFrame, CMDIFrameWnd) //{{AFX_MSG_MAP(CGuiMDIFrame) ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview) ON_WM_SYSCOLORCHANGE() + ON_WM_INITMENUPOPUP() //}}AFX_MSG_MAP END_MESSAGE_MAP() *************** *** 519,520 **** --- 520,605 ---- pBar->MoveWindow(rBar); } + + /// Replace More windows dialog in window menu + /* Code from Yogesh Jagota + * CodeGuru: Adding a Customized 'More windows...' dialog to an MDI application + */ + void CGuiMDIFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) + { + CMDIFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu); + + // If the number of active windows is zero, the window submenu + // probably does'nt esists. If you have the window submenu present + // even in zero child windows, remove this code. + + int nCount = 0; + CWnd * pWnd = GetWindow (GW_CHILD); + ASSERT (pWnd); + pWnd = pWnd->GetWindow (GW_CHILD); + while (pWnd) + { + nCount++; + pWnd = pWnd->GetWindow (GW_HWNDNEXT); + } + + // The count is zero. exit. + if ( nCount == 0 ) + return; + + // If it's a system menu, we don't need to handle that... + if ( !bSysMenu ) + { + // The default handler places the "more windows" command in the + // submenu which contains IDs between AFX_IDM_FIRST_MDICHILD and + // AFX_IDM_LAST_MDICHILD, so check the popup for occurence of + // AFX_IDM_FIRST_MDICHILD. + + int nLength = pPopupMenu->GetMenuItemCount(); + for ( int i = 0; i < nLength; i++ ) + { + if ( pPopupMenu->GetMenuItemID( i ) == AFX_IDM_FIRST_MDICHILD ) + { + // Found. If the last item is already the "more windows" + // command than remove it. + if ( pPopupMenu->GetMenuItemID( nLength - 1 ) == + AFX_IDM_FIRST_MDICHILD + DEFAULT_NUMBER_OF_MDIS ) + { + pPopupMenu->DeleteMenu( nLength - 1, MF_BYPOSITION ); + } + + // Add our own window command. + // Note : The ID must be - ( AFX_IDM_FIRST_MDICHILD + + // ( total number of entries in window list supported ) ). + // This saves us to make any default handler for the + // command, as the default procedure itself + // handles the command and sends it to the mainframe class. + pPopupMenu->AppendMenu(MF_ENABLED|MF_STRING, + AFX_IDM_FIRST_MDICHILD + DEFAULT_NUMBER_OF_MDIS, + _T("&Windows...") ); + + // Done the processing. + return; + } + } + } + } + + /// Show our own More windows dialog + BOOL CGuiMDIFrame::OnCommand(WPARAM wParam, LPARAM lParam) + { + // If the command is "more windows" command call our + // own customized dialog + if ( wParam == AFX_IDM_FIRST_MDICHILD + 9 ) + { + // Replace CWindowDlg with your own class + CGuiMDIWindowsDlg dlgWindowDlg(this); + dlgWindowDlg.DoModal(); + + // OK. We handled the command so return true, + // as we don't want the default handler to + // handle this command too. + return TRUE; + } + + return CMDIFrameWnd::OnCommand(wParam, lParam); + } \ No newline at end of file Index: GuiMDIFrame.h =================================================================== RCS file: /cvsroot/anyedit/AnyEditToolkit/GuiLib/GuiMDIFrame.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** GuiMDIFrame.h 15 Oct 2004 14:01:50 -0000 1.3 --- GuiMDIFrame.h 21 Nov 2004 14:04:41 -0000 1.4 *************** *** 110,120 **** // Generated message map functions //{{AFX_MSG(CGuiMDIFrame) - // NOTE - the ClassWizard will add and remove member functions here. afx_msg void OnFilePrintPreview(); afx_msg void OnSysColorChange( ); //}}AFX_MSG DECLARE_MESSAGE_MAP() virtual void OnUpdateFrameTitle(BOOL bAddToTitle); }; --- 110,125 ---- // Generated message map functions //{{AFX_MSG(CGuiMDIFrame) afx_msg void OnFilePrintPreview(); afx_msg void OnSysColorChange( ); + afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); //}}AFX_MSG DECLARE_MESSAGE_MAP() virtual void OnUpdateFrameTitle(BOOL bAddToTitle); + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + protected: + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL }; |