Print Page | Close Window

CXTPScrollBarCtrl for all Controls

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=23989
Printed Date: 21 November 2024 at 7:03am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CXTPScrollBarCtrl for all Controls
Posted By: cpede
Subject: CXTPScrollBarCtrl for all Controls
Date Posted: 04 June 2020 at 11:08am
I can see that there exist a CXTPScrollBarCtrl class, which can be themed. However most XT control does not use that control, meaning that scrollbars in e.g. property grids, lists etc are not themed.

How can I use the CXTPScrollBarCtrl in all controls and windows to get my scroll bars themed?

Is there a trick to subclass or replace the existing scrollbars?


-------------
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)



Replies:
Posted By: dbrookes
Date Posted: 04 June 2020 at 11:23pm
Ahh yes... scrollbars...

Unfortunately I don't think it's an easy fix. There is some useful information here https://docs.microsoft.com/en-us/windows/win32/controls/about-scroll-bars#standard-scroll-bars-and-scroll-bar-controls" rel="nofollow - https://docs.microsoft.com/en-us/windows/win32/controls/about-scroll-bars#standard-scroll-bars-and-scroll-bar-controls . We're currently looking at similar problems in our XTP application. From what I've been looking there are a few options:


1) First disable the inbuilt scrollbar of the control (if its a list box remove WS_VSCROLL style) and second tie the control together with an CXTPScrollBar. I've done this once with a markup list box on a ribbon backstage (which is essentially a dialog) and it seems to work okay (still in testing).

In this case the scrollbar is a sibling of the list box and the parent updates its position to be next to the list box and the scrollbar's SCROLLINFO on WM_SIZE. For SCROLLINFO I use the number of visible list box items as the page size and total number of list box items as the max.

The parent window implements WM_VSCROLL to handle changes from the CXTPScrollBar. The parent window also hooks the list box window to handle WM_KEYDOWN VK_UP/VK_DOWN and WM_VSCROLL to update the scroll bar.

For the list box I use SetTopIndex and GetTopIndex to update to and from the list box. Tree controls are a little different, I haven't had time to look at these yet.

Hopefully this is enough of an explanation to try reproduce this and hopefully what I've done isn't terrible.

Another idea I had was to wrap the list box in a "scrollbar container" window which moves the clipped child window inside. I think it would allow smooth scrolling which might be nice. I've not tried this though it may be a terrible idea.


2) Set the window theme of the control to take advantage of Windows 10's recently added dark theme.
::SetWindowTheme(hwnd, "DarkMode_Explorer", NULL)
This should give you a dark themed scroll bar. I've tested this on XTP's tree controls by doing the following patch to CXTPTreeBase::RefreshMetrics...
if (m_bExplorerTheme)
  {
  CString strTheme = m_pTheme->IsThemeDark() ? L"DARKMODE_EXPLORER" : L"EXPLORER";
  m_pWindowsTreeTheme->SetWindowTheme(m_pTreeCtrl->GetSafeHwnd(), strTheme, NULL);
  }

3) Implement your own versions of common controls.

4) Don't use Win32, ok great.

XTP does have a class named CXTPScrollBarContainer which it uses internally for some stuff. I've not been able to figure out how to use it correctly. Help would be appreciated there :)

Also, XTP's skin framework does replace these built-in scrollbars somehow. Not sure on the implementation there but from my testing the skin framework doesn't work very well with high DPI scaling. We don't use skin framework in our application.

I would also appreciate any help with this :)


Posted By: dbrookes
Date Posted: 17 June 2020 at 2:16am
Forget everything I said :)

v19.2.0 has been released with some stuff for this. I will have to check it out. Thanks XTP.


Posted By: cpede
Date Posted: 17 June 2020 at 4:52pm
Yes, it will be interesting to see if they added this to all XTToolkit controls; like PropertyEditor, Report, MarkupScroll, TaskPanel etc. Its all or nothing...

-cpede


-------------
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)


Posted By: astoyan
Date Posted: 18 June 2020 at 12:22am
I'm glad to inform you that this issue has finally been addressed in 19.2, and as dbrookes mentioned above, it was quite a tricky task due to the way standard windowless scrollbars are implemented for Windows common controls.

Please refer to the following FAQ article that explains the solution -  https://codejock.com/support/articles/mfc/general/scrollablectrls.asp" rel="nofollow - https://codejock.com/support/articles/mfc/general/scrollablectrls.asp

GUI_VisualStudio sample demonstrates most of those scroll bars in action.

We are aware of some minor issues and it is to be yet added to combo box, so there is some room for improvements. Your feedbacks will help us identify and fix issues faster.

Regards,
  Alexander


Posted By: cpede
Date Posted: 18 June 2020 at 3:31am
Great news I will test.

What about scrollbars in markup <ScrollViewer /> ?

-cpede


-------------
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)


Posted By: lrenoux
Date Posted: 25 June 2020 at 9:55am
I tried but the explanation page for controls deriving from CWnd is slightly succinct and wrong !

Could we have a sample for this specific case ?

L.


Posted By: yangyanhui
Date Posted: 09 March 2021 at 10:53pm
how to tie a CXTPEDIT with  a CXTPScrollBar? the version of codejock is 17.3.0


Posted By: markr
Date Posted: 25 January 2022 at 7:31pm
> Set the window theme of the control to take advantage of Windows 10's recently added dark theme.

Has anyone found a way to make this option work with markup scrollbars (e.g. ScrollViewer)?


Posted By: Pesci7
Date Posted: 18 July 2022 at 9:19am
Scollbars in markup are drawn in CXTPMarkupScrollBar::OnRender using CXTPWinThemeWrapper

        CXTPWinThemeWrapper m_themeScrollBar;
        m_themeScrollBar.OpenThemeData(NULL, L"SCROLLBAR");

I have found that you can take advantage of dark theme passing "DarkMode_Explorer::ScrollBar" instead of "SCROLLBAR" (also "Explorer::ScrollBar" is a valid name). You can also pass a list of name "DarkMode_Explorer::ScrollBar;SCROLLBAR" in case dark mode is not supported.

What's missing is a way to select light or dark theme using code.


-------------
Product: Xtreme ToolkitPro (22.1.0)
Platform: Windows 11 (x64)
Language: Visual Studio 2022 (C++)



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