LRESULT CMainFrame::OnExtMenuPrepare(WPARAM wParam, LPARAM lParam) { wParam; lParam; #if (defined _AFXDLL && !defined __STATPROFUIS_WITH_DLLMFC__) ////////////////////////////////////////////////////////////////////////// // Add "Windows..." command ////////////////////////////////////////////////////////////////////////// CExtPopupMenuWnd::MsgPrepareMenuData_t * pData = reinterpret_cast < CExtPopupMenuWnd::MsgPrepareMenuData_t * > ( wParam ); ASSERT( pData != NULL ); CExtPopupMenuWnd * pPopup = pData->m_pPopup; ASSERT( pPopup != NULL ); INT nItemPos; INT nNewPos = -1; nItemPos = pPopup->ItemFindPosForCmdID( __ID_MDIWND_DLGWINDOWS ); if( nItemPos > 0 ) { // "More Windows..." command found pPopup->ItemRemove( nItemPos ); nNewPos = nItemPos; } else { int nMaxCmdID = 0; for( int nCmdID = __ID_MDIWNDLIST_FIRST; nCmdID <= __ID_MDIWNDLIST_LAST; nCmdID++ ){ nItemPos = pPopup->ItemFindPosForCmdID( nCmdID ); if( nItemPos > 0 ){ if( nCmdID > nMaxCmdID ){ nMaxCmdID = nCmdID; nNewPos = nItemPos; } } } if( nNewPos > 0 ){ pPopup->ItemInsert( (UINT)CExtPopupMenuWnd::TYPE_SEPARATOR, ++nNewPos ); nNewPos++; } } if( nNewPos > 0 ) { UINT nCmdID = ID_WINDOWS_LIST; CExtCmdItem * pCmdItem = g_CmdManager->CmdGetPtr( g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ), nCmdID ); if( pCmdItem == NULL ){ pCmdItem = g_CmdManager->CmdAllocPtr( g_CmdManager->ProfileNameFromWnd( this->GetSafeHwnd() ), nCmdID ); } ASSERT( pCmdItem != NULL ); if( pCmdItem != NULL ) { CString sMoreWindows(_T("Windows...")); CString sManageWindows(_T("Manages the currently open windows")); pCmdItem->m_sMenuText = sMoreWindows; pCmdItem->m_sToolbarText = pCmdItem->m_sMenuText; pCmdItem->m_sTipTool = sManageWindows; pCmdItem->m_sTipStatus = pCmdItem->m_sTipTool; pCmdItem->StateSetBasic( true ); pPopup->ItemInsert( nCmdID, nNewPos, sMoreWindows, NULL, m_hWnd ); } } #endif // #if (defined _AFXDLL && !defined __STATPROFUIS_WITH_DLLMFC__) return 1; }
bool CExtThemeSwitcherToolControlBar::ThemeSwitcherInit( CExtThemeSwitcherToolControlBar::e_ThemeIconSize_t _eTIS_PopupMenu, // = __ETIS_16x16 CExtThemeSwitcherToolControlBar::e_ThemeIconSize_t _eTIS_ToolBar // = __ETIS_24x24 ) { ASSERT_VALID( this ); if( GetSafeHwnd() == NULL ) return false; static const UINT g_arrToolBarResources[] = { IDB_EXT_PM_16x16, IDB_EXT_PM_24x24, IDB_EXT_PM_32x32, }; if( ! m_bCommandProfileInitialized ) { g_CmdManager->CmdRemoveAll( LPCTSTR(m_strCommandProfileName) ); m_mapCmd2RTC.RemoveAll(); m_mapCmdID2ThemeType.RemoveAll(); m_listCmdSequence.RemoveAll(); int nToolBarIndex, nToolBarCount = sizeof(g_arrToolBarResources) / sizeof(g_arrToolBarResources[0]); for( nToolBarIndex = 0; nToolBarIndex < nToolBarCount; nToolBarIndex ++ ) { m_arrMapsTT[nToolBarIndex].RemoveAll(); UINT nToolBarResourceID = g_arrToolBarResources[nToolBarIndex]; HRSRC hRsrcCommands = NULL; HINSTANCE hInstResourceCommands = g_ResourceManager->FindResourceHandle( RT_TOOLBAR, nToolBarResourceID, NULL, &hRsrcCommands ); if( hInstResourceCommands == NULL ) return false; HRSRC hRsrcBitmap = NULL; HINSTANCE hInstResourceBitmap = g_ResourceManager->FindResourceHandle( RT_BITMAP, nToolBarResourceID, NULL, &hRsrcBitmap ); if( hInstResourceBitmap == NULL ) return false; ASSERT( hRsrcBitmap != NULL ); CExtCmdProfile::MFC_TOOLBAR_LOADER _loader( hInstResourceCommands, hRsrcCommands, hInstResourceBitmap, hRsrcBitmap, COLORREF(-1L) ); if( _loader.IsEmpty() ) return false; int nButtonIdx = 0, nCommandIdx, nCommandCount = _loader.GetCommandCount(); ASSERT( nCommandCount > 0 ); for( nCommandIdx = 0; nCommandIdx < nCommandCount; nCommandIdx++ ) { UINT nCommandCmdID = _loader.GetCommandIdAt( nCommandIdx ); if( nCommandCmdID == ID_SEPARATOR ) { if( nToolBarIndex == 0 ) m_listCmdSequence.AddHead( UINT(ID_SEPARATOR) ); continue; } CExtCmdIcon * pIcon = new CExtCmdIcon; UINT nButtonCmdID = _loader.ExtractButtonData( nButtonIdx ++, *pIcon ); ASSERT( nButtonCmdID == nCommandCmdID ); if( pIcon->IsEmpty() ) { ASSERT( FALSE ); delete pIcon; continue; } CRuntimeClass * pRTC = NULL; switch( nButtonCmdID ) { case ID_EXT_PM_THEME_Office2000: pRTC = RUNTIME_CLASS(CExtPaintManager); break; case ID_EXT_PM_THEME_OfficeXP: pRTC = RUNTIME_CLASS(CExtPaintManagerXP); break; case ID_EXT_PM_THEME_Office2003: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2003); break; case ID_EXT_PM_THEME_Office2003NoThemes: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2003NoThemes); break; case ID_EXT_PM_THEME_Studio2005: pRTC = RUNTIME_CLASS(CExtPaintManagerStudio2005); break; case ID_EXT_PM_THEME_Studio2008: pRTC = RUNTIME_CLASS(CExtPaintManagerStudio2008); break; case ID_EXT_PM_THEME_Studio2010: pRTC = RUNTIME_CLASS(CExtPaintManagerStudio2010); break; case ID_EXT_PM_THEME_NativeXP: pRTC = RUNTIME_CLASS(CExtPaintManagerNativeXP); break; case ID_EXT_PM_THEME_Office2007_R1: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2007_R1); break; case ID_EXT_PM_THEME_Office2007_R2_LunaBlue: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_LunaBlue); break; case ID_EXT_PM_THEME_Office2007_R2_Obsidian: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_Obsidian); break; case ID_EXT_PM_THEME_Office2007_R2_Silver: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2007_R2_Silver); break; case ID_EXT_PM_THEME_Office2007_R3_LunaBlue: if( ! m_bEnableOffice2007r3 ) { delete pIcon; continue; } pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2007_R3_LunaBlue); break; case ID_EXT_PM_THEME_Office2007_R3_Obsidian: if( ! m_bEnableOffice2007r3 ) { delete pIcon; continue; } pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2007_R3_Obsidian); break; case ID_EXT_PM_THEME_Office2007_R3_Silver: if( ! m_bEnableOffice2007r3 ) { delete pIcon; continue; } pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2007_R3_Silver); break; case ID_EXT_PM_THEME_Office2010_R1: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2010_R1); break; case ID_EXT_PM_THEME_Office2010_R2_Blue: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2010_R2_Blue); break; case ID_EXT_PM_THEME_Office2010_R2_Silver: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2010_R2_Silver); break; case ID_EXT_PM_THEME_Office2010_R2_Black: pRTC = RUNTIME_CLASS(CExtPaintManagerOffice2010_R2_Black); break; } // switch( nButtonCmdID ) CExtCmdItem * pCmdItem = g_CmdManager->CmdAllocPtr( LPCTSTR(m_strCommandProfileName) ); if( pCmdItem == NULL ) { ASSERT(FALSE); delete pIcon; continue; } pCmdItem->StateSetBasic(); UINT nSavedCmdID = pCmdItem->m_nCmdID; pCmdItem->m_nCmdID = nButtonCmdID; pCmdItem->TipsLoad(); pCmdItem->m_nCmdID = nSavedCmdID; pCmdItem->m_sMenuText = pCmdItem->m_sTipTool = pCmdItem->m_sTipStatus; VERIFY( g_CmdManager->CmdSetIcon( LPCTSTR(m_strCommandProfileName), pCmdItem->m_nCmdID, pIcon, true ) ); if( pRTC != NULL ) { m_mapCmd2RTC.SetAt( pCmdItem->m_nCmdID, pRTC ); } m_mapCmdID2ThemeType.SetAt( pCmdItem->m_nCmdID, nButtonCmdID ); m_arrMapsTT[nToolBarIndex].SetAt( nButtonCmdID, pCmdItem->m_nCmdID ); if( nToolBarIndex == 0 ) m_listCmdSequence.AddHead( nButtonCmdID ); } // for( nCommandIdx = 0; nCommandIdx < nCommandCount; nCommandIdx++ ) } // for( nToolBarIndex = 0; nToolBarIndex < nToolBarCount; nToolBarIndex ++ ) m_bCommandProfileInitialized = true; } // if( ! m_bCommandProfileInitialized ) int nCmdIndex, nCmdCount = int( m_listCmdSequence.GetCount() ); if( nCmdCount == 0 ) return false; m_eTIS_PopupMenu = _eTIS_PopupMenu; m_eTIS_ToolBar = _eTIS_ToolBar; UINT * pArr = NULL; bool bButtonsInitialized = false; try { SetButtons(); POSITION pos = m_listCmdSequence.GetHeadPosition(); pArr = new UINT [ nCmdCount ]; for( nCmdIndex = 0; nCmdIndex < nCmdCount; nCmdIndex++ ) { UINT nMarkerCmdID = m_listCmdSequence.GetNext( pos ); UINT nEffectiveCmdID = ID_SEPARATOR; if( nMarkerCmdID != ID_SEPARATOR ) { VERIFY( m_arrMapsTT[ int(m_eTIS_ToolBar) ]. Lookup( nMarkerCmdID, nEffectiveCmdID ) ); } pArr[ nCmdIndex ] = nEffectiveCmdID; } // for( nCmdIndex = 0; nCmdIndex < nCmdCount; nCmdIndex++ ) bButtonsInitialized = SetButtons( pArr, nCmdCount ) ? true : false; } catch( CException * pException ) { pException->Delete(); } catch( ... ) { } if( pArr != NULL ) delete [] pArr; if( ! bButtonsInitialized ) return false; return true; }