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 :)
|