Print Page | Close Window

EnableFrameTheme when CMainFrame is not main wnd

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=18597
Printed Date: 11 September 2025 at 8:32pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: EnableFrameTheme when CMainFrame is not main wnd
Posted By: Cyprien
Subject: EnableFrameTheme when CMainFrame is not main wnd
Date Posted: 28 June 2011 at 8:46am
Hello,

The software I'm working on has a very particular configuration. The CXTPFrameWnd derived class is not the main window of the application. The CMainFrame window is in a COleControl, and the COleControl is in a CDialog. (This allow an ActiveX usage of CMainFrame). For the user it's just like if there where only a the main frame.
I can use a ribbon in my main frame, but when I call EnableFrameTheme, It does'nt work as expected :
The mainframe can be moved inside the main dialog !

I tried some modification in ToolkitPro sources in order to have CXTPRibbonBar::GetSite() and CXTPOffice2007FrameHook::m_hwndSite be the parent window of the application. It solves some problems but it's not enough : the maximize/minimize/close buttons don't work.

Can someone help me please ?

Thanks
Cyprien 



Replies:
Posted By: Oleg
Date Posted: 29 June 2011 at 2:59am
So your dialog don't have frame/caption and you want that your child frame as replacement of dialog's ?

If you don't call EnableFrameTheme it works like you expected ?  



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Cyprien
Date Posted: 29 June 2011 at 3:30am
Hi Oleg,

My Dialog has a caption and borders, the main frame has no caption and no border.
If I don't call EnableFrameTheme I Can see the dialog caption and below the ribbon and it works as expected.

Here is a sample project I did yesterday which reproduces the problem
uploads/6868/RibbonFrameTheme.zip - uploads/6868/RibbonFrameTheme.zip

When you click on EnableFrameTheme (in the ribbon) there are no visual changes but you can move the window containing the ribbon inside the dialog box.

The following modifications produces a better visual result but doesn't fully work :
In XTPCommandBar.h line 371 add virtual before CWnd* GetSite() const;
In XTPOffice2007FrameHook.cpp, CXTPOffice2007FrameHook::EnableOffice2007Frame(CXTPCommandBars* pCommandBars)
replace

  if (pCommandBars)
    {
#ifdef _XTP_INCLUDE_RIBBON
      m_pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, pCommandBars->GetMenuBar());
#endif
      m_hwndSite = pCommandBars->GetSite()->GetSafeHwnd();
  }


with

  if (pCommandBars)
  {
#ifdef _XTP_INCLUDE_RIBBON
    m_pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, pCommandBars->GetMenuBar());
#endif
    m_hwndSite = pCommandBars->GetSite()->GetSafeHwnd();
    if (m_hwndSite)
    {
      HWND hParent = GetParent(m_hwndSite);
      while (hParent)
      {
        m_hwndSite = hParent;
        hParent = GetParent(hParent);
      }
    }
  }

In CXTPRibbonBar, overload the virtual method virtual CWnd* GetSite() const; with

CWnd* CXTPRibbonBar::GetSite() const
{
  if (IsFrameThemeEnabled())
  {
    return m_pFrameHook->GetSite();
  }
  else
  {
    return __super::GetSite();
  }
}


Posted By: Oleg
Date Posted: 30 June 2011 at 2:33am
Hi,

For Child frames I don't recommend you such workarounds. Just don't call EnableFrameTheme.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



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