Print Page | Close Window

[SOLVED]PropertySheet theme issue

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=24197
Printed Date: 22 December 2024 at 12:16pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED]PropertySheet theme issue
Posted By: xsensordev
Subject: [SOLVED]PropertySheet theme issue
Date Posted: 20 August 2021 at 2:46pm
I've modified the Samples\Controls\PropertySheet sample that comes with Toolkit Pro 20.0 to test the effect of the Windows 10 dark theme on it.

If the CXTPPropertySheet::SetTheme function is called BEFORE the CXTPPropertySheet::SetNavigator call, then I get this look:






If the CXTPPropertySheet::SetTheme function is called AFTER the CXTPPropertySheet::SetNavigator call, then I get this look:




Where's the title bar?


To achieve this effect, I only modified CPropertySheetApp::InitInstance() and CPropertySheetDlg::OnButtonList().

My changes are BOLDED

BOOL CPropertySheetApp::InitInstance()
{
AfxEnableControlContainer();

// Standard initialization
// If you are not using these features and wish to reduce the size
//  of your final executable, you should remove from the following
//  the specific initialization routines you do not need.

#if _MSC_VER <= 1200 // MFC 6.0 or earlier
# ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
# else
Enable3dControlsStatic(); // Call this when linking to MFC statically
# endif
#endif // MFC 6.0 or earlier

XTPThemeDLL()->SetHandle(xtpIniWindows10Dark);
XTPPaintManager()->SetTheme(XTPPaintTheme::xtpThemeNativeWindows10);
CPropertySheetDlg dlg;
m_pMainWnd = &dlg;
int nResponse = (int)dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with Cancel
}

// Since the dialog has been closed, return FALSE so that we exit the
//  application, rather than start the application's message pump.
return FALSE;
}

void CPropertySheetDlg::OnButtonList()
{
CXTPPropertySheet ps(_T("CXTPPropertyPageListNavigator Sample"));

// The pages do not receive the theme if I call this here.
// ps.SetTheme(xtpControlThemeNativeWindows10);


CXTPPropertyPageListNavigator* pList = new CXTPPropertyPageListNavigator();
pList->SetListStyle(xtpListBoxNativeWindows10);

ps.SetNavigator(pList);

// The pages receive the theme, but the titlebar goes blank.
ps.SetTheme(xtpControlThemeNativeWindows10);

CTabListPage pageProperties;
CTabSamplePage pageSample;
CTabResizablePage pageSize;

ps.AddPage(&pageProperties);
ps.AddPage(&pageSample);
ps.AddPage(&pageSize);

ps.SetResizable();

ps.DoModal();
}


If you switch to the theme to xtpIniWindows10Light, its the same bad titlebar effect:




Am I doing something wrong?





Replies:
Posted By: xsensordev
Date Posted: 20 August 2021 at 5:56pm
Okay I've spent several hours digging through the maze of cj code and managed to figure out the issue.

The CXTPPropertySheet::SetTheme() call after the call to SetNavigator() causes CXTPCommandBars::EnableFrameTheme(TRUE) to be executed later in the call stack.

The colors for the frame are in fact properly read from the INI dll via a call to
CXTPFrameThemeOffice2013::RefreshMetrics()
 

However, those colors are then wiped out with calls to XTPGetAccentColor() in CXTPFrameThemeNativeWindows10::RefreshMetrics().

Anyway my fix is to replace that function with the following:

void CXTPFrameThemeNativeWindows10::RefreshMetrics()
{
CXTPFrameThemeOffice2013::RefreshMetrics();

m_clrShadowColorActive   = XTPIniColor(_T("CommandBars.Frame"), _T("ActiveShadowColor"),
   RGB(0, 122, 204));
m_clrShadowColorInactive = XTPIniColor(_T("CommandBars.Frame"), _T("InactiveShadowColor"),
   RGB(48, 48, 48));

#if(0) // what is this fluff?
// frame back color
m_clrFrameBorderActive.SetStandardValue(XTPGetAccentColor(xtpPaintManagerAccentColor));
m_clrFrameCaptionActive.SetStandardValue(XTPGetAccentColor(xtpPaintManagerAccentColor));

// frame caption text
m_clrFrameCaptionTextActive.SetStandardValue(
XTPGetAccentColor(xtpPaintManagerNormalTextAccentColor));
m_clrFrameCaptionTextActiveBSMode.SetStandardValue(
XTPGetAccentColor(xtpPaintManagerNormalTextAccentColor));

// minimize/maximize/restore button text
m_csFrameCaptionButtonActive.m_clrBackground.SetStandardValue(
XTPGetAccentColor(xtpPaintManagerAccentColor));
m_csFrameCaptionButtonActive.m_clrFill.SetStandardValue(
XTPGetAccentColor(xtpPaintManagerNormalTextAccentColor));

// close button text
m_csFrameCloseButtonActive.m_clrBackground.SetStandardValue(
XTPGetAccentColor(xtpPaintManagerAccentColor));
m_csFrameCloseButtonActive.m_clrFill.SetStandardValue(
XTPGetAccentColor(xtpPaintManagerNormalTextAccentColor));
#endif
}


Posted By: agontarenko
Date Posted: 26 August 2021 at 4:30am
Hello,

See please CCustomizePageGeneral class in RibbonSample. I think, this class contains same functional what you need. You can to use XAML for controls with black themes in CXTPPropertyPage.



Regards
Artem Gontarenko


Posted By: xsensordev
Date Posted: 26 August 2021 at 11:25am
Thank you Artem, I will give it a try.

Best regards
Terry R. @ xsensor.com



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