Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Docking Pane
  New Posts New Posts RSS Feed - Making dockingpane color match ribbon color
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Making dockingpane color match ribbon color

 Post Reply Post Reply
Author
Message
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Topic: Making dockingpane color match ribbon color
    Posted: 18 June 2008 at 8:24pm
Hello.  I have an application that uses the ribbon, and also has docking panes.  I'm giving users the option of changing the color scheme of the ribbon (blue, black, silver, aqua).  However, I can not figure out how to change the docking pane color scheme to match.

I've tried the following code, but it doesn't work.  What am I missing?

HMODULE hModule = AfxGetInstanceHandle();
LPCTSTR lpszIniFile = _T("OFFICE2007BLACK.INI"); break;
 
XTPOffice2007Images()->SetHandle(hModule, lpszIniFile);
m_paneManager.GetPaintManager()->RefreshMetrics();
m_paneManager.RedrawPanes();

Thanks.

Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2008 at 8:35pm
BTW, I have already set the docking pane theme to xtpPaneThemeOffice2007.  But the docking panes always have the blue color scheme, no matter what color scheme I chose for the ribbon.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 1:42am
Hi,
 
Do you have 12.0 release ?
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 1:20pm
No, I'm using 11.1.3.  Are you saying that this has been fixed in 12.0?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 2:04pm
Hi,
Yes, think so.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 3:13pm
Ok, I will download v12.  But what code do I have to use in order to make the docking panes change color?  Is it the code I posted above or something else?  Does it happen automatically?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 3:29pm
Hi,
 
Yes, think this code will work for 12.0. You can download eval version to check.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 4:30pm
I downloaded v12 and recompiled my project with it, but it still doesn't work.  Is there a particular function I need to call?
Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 5:11pm
I've debugged into the CXTPDockingPaneOffice2007Theme::RefreshMetrics() function, and can see that the clrNormalCaption and clrActiveCaption values being returned from XTPOffice2007Images()->GetImageColor() are always the blue colors. 

So it would appear that the XTPOffice2007Images()->SetHandle() function is not setting the images correctly...
Back to Top
Smucker View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 February 2008
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote Smucker Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 8:39pm
I have a method called "SetAllTheme" to try to keep various pieces in sync, and it is working for me in 12.0. As far as I remember, it worked in 11.2 as well.

void CMainFrame::SetAllTheme(XTPPaintTheme theme, PCTSTR ini_file)
{
    XTPDockingPanePaintTheme panetheme = xtpPaneThemeDefault;
    XTPPropertyGridPaintTheme gridtheme = xtpGridThemeDefault;
    CXTPCommandBars* pbars = GetCommandBars();
    pbars->SetTheme(theme);
    XTPPaintManager()->SetTheme(theme);
    switch (theme) {
    case xtpThemeOfficeXP:
    case xtpThemeOffice2000:
        panetheme = xtpPaneThemeOffice;
        gridtheme = xtpGridThemeOfficeXP;
        break;
    case xtpThemeOffice2003:   
        panetheme = xtpPaneThemeOffice2003;
        gridtheme = xtpGridThemeOffice2003;
        break;
    case xtpThemeNativeWinXP:
        panetheme = xtpPaneThemeNativeWinXP;
        gridtheme = xtpGridThemeNativeWinXP;
        break;
    case xtpThemeOffice2007:
        panetheme = xtpPaneThemeOffice2007;
        gridtheme = xtpGridThemeOffice2007;
        break;
    case xtpThemeRibbon:
        panetheme = xtpPaneThemeOffice2007;
        gridtheme = xtpGridThemeOffice2007;
        break;
    default:
        panetheme = xtpPaneThemeDefault;
        gridtheme = xtpGridThemeDefault;
        break;
    }
    m_paneManager.SetTheme(panetheme);
    m_wndProp.SetTheme(gridtheme);
    if ( (theme == xtpThemeOffice2007 || theme == xtpThemeRibbon) && ini_file) {
        ((CXTPOffice2007Theme*)pbars->GetPaintManager())
             ->SetImageHandle(AfxGetInstanceHandle(), ini_file);
        ((CXTPOffice2007Theme*)XTPPaintManager())
             ->SetImageHandle(AfxGetInstanceHandle(), ini_file);
    }
    m_paneManager.UpdatePanes();
    m_paneManager.GetPaintManager()->GetPanelPaintManager()
           ->SetLayout(xtpTabLayoutAutoSize);
    m_paneManager.GetPaintManager()->RefreshMetrics();
    m_paneManager.RedrawPanes();
    XTPPaintManager()->RefreshMetrics();
    pbars->GetImageManager()->RefreshAll();
    pbars->RedrawCommandBars();
    theApp.m_panetheme = panetheme;
    theApp.m_gridtheme = gridtheme;
    theApp.m_painttheme = theme;
    _tcscpy_s(theApp.theme_ini, TSIZE(theApp.theme_ini), ini_file ? ini_file : _T(""));
    SaveAppPreferences();
}


Then I set the black theme using:

        SetAllTheme(xtpThemeOffice2007, _T("OFFICE2007BLACK.INI"))

Some of the things I'm doing probably aren't necessary, but I haven't worked on paring it down yet.

If you're linking statically like I do, be sure that you include the necessary resources in your .rc2 file:


#include <XTToolkitPro.rc>
#include "Styles\Office2007Blue\Office2007Blue.rc"
#include "Styles\Office2007Aqua\Office2007Aqua.rc"
#include "Styles\Office2007Black\Office2007Black.rc"
#include "Styles\Office2007Silver\Office2007Silver.rc"
#include "SkinFramework\Styles\Office2007\Office2007.rc"

Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 19 June 2008 at 10:40pm
Thanks for posting the code Smucker.  Unfortunately, it does not work for me.  The docking pane colors are still not changing.  But one thing you said interests me.  You said you are using static linking; I am just using a dll.

Oleg - have you heard of any problems with changing the docking pane colors when Codejock is compiled as dlls?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2008 at 1:36am

Hi,

Check that you use Office2007Black from last release. Maybe you copied it from 11.1.3 and still use it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2008 at 2:03pm
How can I check to make sure I'm using the right one?  The ribbon color changes correctly, so I would assume the Office2007black is correct.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2008 at 2:10pm

Hi,

Copy it from Source\Styles folder.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2008 at 2:54pm
Yes, I am using the correct Office2007black.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2008 at 3:06pm
Hi,
 
Please modify our Pane sample or any from DockingPane folder and attach it here.  It have to work.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2008 at 4:52pm
Hi.  I modified the Pane sample, and I was able to make the panes change colors.  I also was able to do the same thing in 11.1.3.

All I added was this:

void CMainFrame::OnThemeOffice2007black()
{
    AdjustStyle(xtpPaneThemeOffice);
    SetDockingPaneTheme(xtpPaneThemeOffice2007);
    m_nSelectedTheme = ID_THEME_OFFICE2007BLACK;
   
    HMODULE hModule = AfxGetInstanceHandle();
    LPCTSTR lpszIniFile = _T("OFFICE2007BLACK.INI");
    XTPOffice2007Images()->SetHandle(hModule, lpszIniFile);
    m_paneManager.GetPaintManager()->RefreshMetrics();
   
}

Unfortunately, this does not work in my project.  If I am doing this part correctly, what else might be the problem?  Any general ideas of where I might look within my project?  Pane creation, maybe? 

Back to Top
Smucker View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 February 2008
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote Smucker Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2008 at 8:01pm
HMODULE hModule = AfxGetInstanceHandle();

This gets the HINSTANCE to your EXE (or your user DLL). Don't you need the HINSTANCE for the Codejock DLL?


LPCTSTR lpszIniFile = _T("OFFICE2007BLACK.INI");
XTPOffice2007Images()->SetHandle(hModule, lpszIniFile);

So I think this is trying to find
OFFICE2007BLACK.INI in your EXE or DLL rather than the Codejock DLL. Run in the debugger and setup into SetHandle and make sure that FindResource finds it (XTPOffice2007Image.h line 725 in 12.0.0)

I could be wrong. I often am, and I prefer using/distributing as few DLLs as possible.

Back to Top
tommylov View Drop Down
Groupie
Groupie


Joined: 09 January 2007
Location: United States
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote tommylov Quote  Post ReplyReply Direct Link To This Post Posted: 20 June 2008 at 10:09pm
Thanks for chiming in again, Smucker.  I appreciate you trying to help.

I debugged through the code, and it is picking up the the proper office2007black.ini file.

In fact, when I debugged through XTPOffice2007Images()->SetHandle, I saw that the black profile was retrieved successfully.

But then when I debugged through m_paneManager.GetPaintManager()->RefreshMetrics(), which is the very next line in my code, the profile had been changed back to blue.

Back to Top
Smucker View Drop Down
Senior Member
Senior Member
Avatar

Joined: 02 February 2008
Status: Offline
Points: 156
Post Options Post Options   Thanks (0) Thanks(0)   Quote Smucker Quote  Post ReplyReply Direct Link To This Post Posted: 21 June 2008 at 3:13am
Here's something I did a little differently (cribbed from a CJ sample, I'm sure); maybe it has something to do with something!
((CXTPOffice2007Theme*)XTPPaintManager())->SetImageHandle(AfxGetInstanceHandle(), ini_file);

I also call
m_paneManager.UpdatePanes();

before
m_paneManager.GetPaintManager()->RefreshMetrics();

Another thing to try in the debugger would be to set a data breakpoint on a memory location (such as a color value) that you know is changing between your two lines of code, so you can see what is mucking with it.

Good luck! I know it can work. Here's an example of Office 2007 style black panes with an Office 2007 style command bar::


Full size image



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.188 seconds.