Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - CXTPScrollBarCtrl for all Controls
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CXTPScrollBarCtrl for all Controls

 Post Reply Post Reply
Author
Message
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 645
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Topic: CXTPScrollBarCtrl for all Controls
    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 (20.3.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
dbrookes View Drop Down
Groupie
Groupie


Joined: 30 August 2019
Location: Australia
Status: Offline
Points: 69
Post Options Post Options   Thanks (0) Thanks(0)   Quote dbrookes Quote  Post ReplyReply Direct Link To This Post 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. 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 :)
Back to Top
dbrookes View Drop Down
Groupie
Groupie


Joined: 30 August 2019
Location: Australia
Status: Offline
Points: 69
Post Options Post Options   Thanks (0) Thanks(0)   Quote dbrookes Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 645
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post 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 (20.3.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
astoyan View Drop Down
Admin Group
Admin Group
Avatar

Joined: 24 August 2013
Status: Offline
Points: 284
Post Options Post Options   Thanks (0) Thanks(0)   Quote astoyan Quote  Post ReplyReply Direct Link To This Post 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

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
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 645
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 18 June 2020 at 3:31am
Great news I will test.

What about scrollbars in markup <ScrollViewer /> ?

-cpede
Product: Xtreme ToolkitPro (20.3.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
lrenoux View Drop Down
Groupie
Groupie


Joined: 20 April 2009
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote lrenoux Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
yangyanhui View Drop Down
Senior Member
Senior Member


Joined: 20 August 2020
Status: Offline
Points: 131
Post Options Post Options   Thanks (0) Thanks(0)   Quote yangyanhui Quote  Post ReplyReply Direct Link To This Post Posted: 09 March 2021 at 10:53pm
how to tie a CXTPEDIT with  a CXTPScrollBar? the version of codejock is 17.3.0
Back to Top
markr View Drop Down
Senior Member
Senior Member


Joined: 01 August 2004
Status: Offline
Points: 441
Post Options Post Options   Thanks (0) Thanks(0)   Quote markr Quote  Post ReplyReply Direct Link To This Post 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)?
Back to Top
Pesci7 View Drop Down
Groupie
Groupie
Avatar

Joined: 27 January 2021
Location: Italy
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pesci7 Quote  Post ReplyReply Direct Link To This Post 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++)
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.156 seconds.