Print Page | Close Window

Making dockingpane color match ribbon color

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=11102
Printed Date: 09 May 2024 at 6:04pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Making dockingpane color match ribbon color
Posted By: tommylov
Subject: Making dockingpane color match ribbon color
Date 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.




Replies:
Posted By: tommylov
Date 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.


Posted By: Oleg
Date Posted: 19 June 2008 at 1:42am
Hi,
 
Do you have 12.0 release ?


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


Posted By: tommylov
Date 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?


Posted By: Oleg
Date Posted: 19 June 2008 at 2:04pm
Hi,
Yes, think so.


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


Posted By: tommylov
Date 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?


Posted By: Oleg
Date 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


Posted By: tommylov
Date 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?


Posted By: tommylov
Date 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...


Posted By: Smucker
Date 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"



Posted By: tommylov
Date 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?


Posted By: Oleg
Date 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


Posted By: tommylov
Date 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.


Posted By: Oleg
Date Posted: 20 June 2008 at 2:10pm

Hi,

Copy it from Source\Styles folder.


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


Posted By: tommylov
Date Posted: 20 June 2008 at 2:54pm
Yes, I am using the correct Office2007black.


Posted By: Oleg
Date 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


Posted By: tommylov
Date 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? 



Posted By: Smucker
Date 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.



Posted By: tommylov
Date 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.



Posted By: Smucker
Date 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::


http://www2.cerious.com/binaries/cerious/sev/thumbs8sample.jpg - Full size image






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