1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using CMFCVisualManager to change style of buttons and background of a CFormView

Discussion in 'MFC' started by pengCC, Aug 28, 2010.

  1. pengCC

    pengCC New Member

    Joined:
    Aug 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Dear All,

    I am using VS2008 with MFC feature pack (the one with Ribbons). I would like to use CMFCVisualManager in order to change the background of a CFormView to any Office 2007 style.

    Would anyone know how to do this? At the moment the CMFCVisualManager is called in the MainFrame but this call is not reflected in the children class even if the RDW_ALLCHILDREN is called:

    RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE);

    Code:
    void CMainFrame::OnApplicationLook(UINT id)
    {
            CWaitCursor wait;
    
            theApp.m_nAppLook = id;
    
            switch (theApp.m_nAppLook)
            {
            case ID_VIEW_APPLOOK_WIN_2000:
                    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManager));
                    break;
    
            case ID_VIEW_APPLOOK_OFF_XP:
                    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOfficeXP));
                    break;
    
            case ID_VIEW_APPLOOK_WIN_XP:
                    CMFCVisualManagerWindows::m_b3DTabsXPTheme = TRUE;
                    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
                    break;
    
            case ID_VIEW_APPLOOK_OFF_2003:
                    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2003));
                    CDockingManager::SetDockingMode(DT_SMART);
                    break;
    
            case ID_VIEW_APPLOOK_VS_2005:
                    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerVS2005));
                    CDockingManager::SetDockingMode(DT_SMART);
                    break;
    
            default:
                    switch (theApp.m_nAppLook)
                    {
                    case ID_VIEW_APPLOOK_OFF_2007_BLUE:
                            CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_LunaBlue);
                            break;
    
                    case ID_VIEW_APPLOOK_OFF_2007_BLACK:
                            CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_ObsidianBlack);
                            break;
    
                    case ID_VIEW_APPLOOK_OFF_2007_SILVER:
                            CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Silver);
                            break;
    
                    case ID_VIEW_APPLOOK_OFF_2007_AQUA:
                            CMFCVisualManagerOffice2007::SetStyle(CMFCVisualManagerOffice2007::Office2007_Aqua);
                            break;
                    }
    
                    CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerOffice2007));
                    CDockingManager::SetDockingMode(DT_SMART);
            }
    
            RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW | RDW_FRAME | RDW_ERASE);
    
            theApp.WriteInt(_T("ApplicationLook"), theApp.m_nAppLook);
    } 
    Anyone could help?

    Regards
     

Share This Page