Print Page | Close Window

Office 2013 Theme - Shadow

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=23220
Printed Date: 23 December 2024 at 2:26pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Office 2013 Theme - Shadow
Posted By: mihey
Subject: Office 2013 Theme - Shadow
Date Posted: 05 December 2016 at 7:45am
Hi,
comparing two examples - Ribbon.RibbonControls and Ribbon.RibonSample from the new XTP 17.3 MFC, I found out that the first one shows a shadow around the main window and the second one doesn't.



vs



Both are executed in Windows 7 x64 OS.

Can anybody say which exactly method is responsible for this? I could not find it yet. My application also does not show the shadow at the moment and I'd like to change it.

Regards,
Mikhail.



Replies:
Posted By: olebed
Date Posted: 05 December 2016 at 9:17am
Hello Mikhail,

FrameShadows are turned on with calling 
CXTPCommandBarsFrameHook::EnableFrameTheme(). Differences between these two samples in methods CMainFrame::SetCommandBarsTheme(). 

> ToolkitPro1800UD.dll!CXTPCommandBarsFrameHook::EnableShadow() Line 1387 C++
  ToolkitPro1800UD.dll!CXTPCommandBarsFrameHook::EnableFrameTheme(CXTPCommandBars * pCommandBars) Line 383 C++
  ToolkitPro1800UD.dll!CXTPCommandBarsFrameHook::EnableOffice2007Frame(CXTPCommandBars * pCommandBars) Line 404 C++
  ToolkitPro1800UD.dll!CXTPCommandBars::EnableFrameTheme(int bEnable) Line 2341 C++
  ToolkitPro1800UD.dll!CXTPRibbonBar::EnableFrameTheme(int bEnable) Line 427 C++
  RibbonControls.exe!CMainFrame::SetCommandBarsTheme(XTPPaintTheme paintTheme, HINSTANCE__ * hModule, const wchar_t * lpszINI) Line 1049 C++

Old themes don't have FrameShadows and  pFramePaintManager->CreateShadow(GetSite());  in method CXTPCommandBarsFrameHook::EnableShadow()  returns NULL. So default Ribbon has theme office2007 without frameShadow. But on setting Office2013 theme and enabling "FrameTheme" option again in CXTPCommandBarsFrameHook::EnableFrameTheme()  method exits on begining
void CXTPCommandBarsFrameHook::EnableFrameTheme(CXTPCommandBars* pCommandBars)
{
    BOOL bEnabled = pCommandBars != NULL;
    if (m_bThemeFrameEnabled == bEnabled)
        return;
    ....
    if (pCommandBars)
    {
        ....
        EnableShadow();
    }
    else
    {
        DisableFrameTheme();
    }
}

That is why to enable shadows we need to disable "FrameTheme" and then enable again as in CMainFrame::SetCommandBarsTheme() method of RibbonControls sample.
void CMainFrame::SetCommandBarsTheme(XTPPaintTheme paintTheme, HMODULE hModule/*=NULL*/, LPCTSTR lpszINI/*=NULL*/)
{
    CXTPCommandBarsFrameHook::m_bAllowDwm = !(CXTPWinDwmWrapper().IsCompositionEnabled() && (xtpThemeOffice2013 == paintTheme || xtpThemeOffice2007System == paintTheme));
    CXTPRibbonBar *pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetMenuBar());
    pRibbonBar->EnableFrameTheme(FALSE);

    CXTPCommandBars* pCommandBars = GetCommandBars();
    if (pCommandBars != NULL)
    {
        if (hModule != NULL && lpszINI != NULL)
        {
            XTPResourceImages()->SetHandle(hModule, lpszINI);
            CXTPPaintManager::SetTheme(paintTheme);
        }
        else if(paintTheme == xtpThemeOfficeXP) // System theme
        {
            CXTPPaintManager::SetTheme(paintTheme);
        }
        
        pRibbonBar->EnableFrameTheme(TRUE);
    }
}

In RibbonSample:
void CMainFrame::SetCommandBarsTheme(XTPPaintTheme paintTheme, LPCTSTR lpszINI/*=NULL*/)
{
    ....
    if (!m_bOverrideAllowDwm)
    {
        m_bAllowDwm = (XTPSystemVersion()->IsWin10OrGreater() ? FALSE
            : !(CXTPWinDwmWrapper().IsCompositionEnabled()
                && (xtpThemeOffice2013 == paintTheme || xtpThemeVisualStudio2015 == paintTheme)));
    }
    else
    {
        pRibbonBar->EnableFrameTheme(FALSE);
    }
    ....
        CXTPPaintManager::SetTheme(paintTheme);
    ....
    pRibbonBar->EnableFrameTheme(m_bEnableFrameTheme);
    ....
}

Regards,
 Oleksandr Lebed


Posted By: mihey
Date Posted: 06 December 2016 at 3:12am
Hello Oleksandr,

Thank you very much for the explanation.

Your suggestion has helped. After I've added EnableFrameTheme(FALSE) in
RibbonSample I could turn shadows there on.

In case of my application the problem was also in the moment at which I tried to enable the theme. At this moment the MainWindow was hidden and Ribbon has not been initialized properly. After I moved the Theme initialization to the end of my InitInstance it worked as a should.     

Best regards,
Mikhail


Posted By: olebed
Date Posted: 06 December 2016 at 5:26am
Smile ok, glad to hear this



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net