Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - [SOLVED]PropertySheet theme issue
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

[SOLVED]PropertySheet theme issue

 Post Reply Post Reply
Author
Message Reverse Sort Order
xsensordev View Drop Down
Groupie
Groupie


Joined: 19 August 2021
Location: Canada
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote xsensordev Quote  Post ReplyReply Direct Link To This Post Topic: [SOLVED]PropertySheet theme issue
    Posted: 26 August 2021 at 11:25am
Thank you Artem, I will give it a try.

Best regards
Terry R. @ xsensor.com
Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 202
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
xsensordev View Drop Down
Groupie
Groupie


Joined: 19 August 2021
Location: Canada
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote xsensordev Quote  Post ReplyReply Direct Link To This Post 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
}
Back to Top
xsensordev View Drop Down
Groupie
Groupie


Joined: 19 August 2021
Location: Canada
Status: Offline
Points: 11
Post Options Post Options   Thanks (0) Thanks(0)   Quote xsensordev Quote  Post ReplyReply Direct Link To This Post 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?


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