Print Page | Close Window

Switching Themes on a CXTPTabClientWnd

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=8452
Printed Date: 14 November 2025 at 8:09am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Switching Themes on a CXTPTabClientWnd
Posted By: Jayonas
Subject: Switching Themes on a CXTPTabClientWnd
Date Posted: 17 October 2007 at 3:03pm
I'm working on making a UI that is best described as Visual Studio with a ribbon. I just put in the workspace area, using CXTPTabClientWnd, and was absolutely gleeful that it just picked up the theme that my ribbon was already using and rendered itself appropriately. That is awesome.

I have one minor problem: when I change themes the CXTPTabClientWnd only partially updates itself. The current tab changes to reflect the new theme, but the background behind the tabs and the tabs which aren't selected retain the old theme. Tabs that aren't selected actually use the new theme for their mouseover state, but go back to the old theme after the mouse leaves.

Here's a screenshot:



I started with the black theme and then switched to silver. Resource 1 is the current tab and correctly using the new theme. Resource 0 is not the current tab and is incorrectly using the old theme. Resource 2 has the mouse over it and only uses the new theme while in that state. As soon as the mouse leaves it, it will go back to looking like Resource 0. It's not shown in the picture, but the area of the tab control that has no tabs (including the Close and Arrow buttons) is also still using the old theme.

Here's the code I'm using to change themes:


// record the newly selected theme
m_SelectedTheme = Theme;

// determine the appropriate INI resource to load it from
LPCTSTR IniName = 0;
switch (m_SelectedTheme) {
    case FrameTheme_Aqua:
        IniName = _T("OFFICE2007AQUA_INI");
        break;
    case FrameTheme_Black:
        IniName = _T("OFFICE2007BLACK_INI");
        break;
    case FrameTheme_Blue:
        IniName = _T("OFFICE2007BLUE_INI");
        break;
    case FrameTheme_Silver:
        IniName = _T("OFFICE2007SILVER_INI");
        break;
}

// set the new theme
((CXTPRibbonTheme*)this->GetCommandBars()->GetPaintManager())->SetImageHandle(g_Application.GetHandle(), IniName);

// refresh everything if requested
if (Refresh) {
    this->GetCommandBars()->GetImageManager()->RefreshAll();
    this->GetCommandBars()->RedrawCommandBars();
    this->SendMessage(WM_NCPAINT);
    this->RedrawWindow(0, 0, RDW_ALLCHILDREN | RDW_INVALIDATE);
}


I would normally guess that there's method of CXTPTabClientWnd that I should be calling to have it refresh itself. However, since it at least partially responds to the theme changing (the active tab does change correctly), I'm not so sure that I'm forgetting something. In theory, I'd guess that passing RDW_ALLCHILDREN to RedrawWindow would cause any refreshing necessary (since the CXTPTabClientWnd instance is a child of the class that contains that code, which is the CXTPMDIFrameWnd).

Any ideas?

Thanks!



Replies:
Posted By: Jayonas
Date Posted: 17 October 2007 at 4:21pm
Also, it turns out that I'm having the same problem with docking panes. When two panes are stacked (so they have tabs to switch between them) the tabs are having the exact same problem with not switching themes.

A related question: are the docking pane title bars and Pin/Close buttons supposed to match the ribbon theme? The best I could find to get it to do that was to set the pane manager use xtpPaneThemeOffice2007, but that doesn't seem to work. It would be really nice if the panes could paint their title bars and Pin/Close buttons using the ribbon's paint manager like the tab client window does.

Thanks again!


Posted By: Oleg
Date Posted: 18 October 2007 at 4:46am
Hi,
 
try call Refresh method of TabClient.


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


Posted By: Jayonas
Date Posted: 18 October 2007 at 3:32pm
No luck, unfortunately.

I tried Refresh, RedrawWindow, and UpdateWindow, all to no avail.

Another interesting thing to add to the mix.. I just added a few buttons that create new documents and docking panes arbitrarily. If I switch themes and then create more documents and/or docking panes, even those brand new items are using the old theme. I'd guess that doesn't matter much, since the DockingPaneManager is probably using the same drawing code whether or not its drawing a tab that was created before the switch or after. I figured it couldn't hurt to mention it anyway, though.

Any other ideas?


Posted By: Oleg
Date Posted: 19 October 2007 at 12:40am
Hi,
 
try this:
 
m_pClient->Refresh(); 
m_pClient->GetPaintManager()->RefreshMetrics();   


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


Posted By: Jayonas
Date Posted: 19 October 2007 at 10:32am
Yay, that did it! It turns out that calling Refresh isn't even necessary, RefreshMetrics worked by itself. I made the same call on the DockingPaneManager and it fixed that too.

The docking pane headers and pin/close buttons still render with a different theme than everything else, but I suspect that's by design. It'd be great if they could make use of ribbon styles in a future version. :)

Thanks a lot for your help!


Posted By: shineryu
Date Posted: 02 December 2007 at 11:25pm
Hi,
Try this:
 
m_pPaneManager->GetPaintManager()->RefreshMetrics();
 



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