Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Office 2013 Theme - Shadow
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Office 2013 Theme - Shadow

 Post Reply Post Reply
Author
Message
mihey View Drop Down
Groupie
Groupie
Avatar

Joined: 14 May 2003
Location: Germany
Status: Offline
Points: 45
Post Options Post Options   Thanks (0) Thanks(0)   Quote mihey Quote  Post ReplyReply Direct Link To This Post Topic: Office 2013 Theme - Shadow
    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.
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mihey View Drop Down
Groupie
Groupie
Avatar

Joined: 14 May 2003
Location: Germany
Status: Offline
Points: 45
Post Options Post Options   Thanks (0) Thanks(0)   Quote mihey Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
olebed View Drop Down
Admin Group
Admin Group


Joined: 01 July 2014
Location: Ukraine
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote olebed Quote  Post ReplyReply Direct Link To This Post Posted: 06 December 2016 at 5:26am
Smile ok, glad to hear this
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.203 seconds.