OutlineListbox

From Team Developer SqlWindows Wiki
Revision as of 23:06, 22 November 2021 by DaveRabelink (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

VT OutlineListbox control


Contents


Pointer2.png cOutlineListBox: workaround for the ugly mousewheel-scroll visual effect Pointer.png

When scrolling the contents of cOutlineListbox (or any other VT listbox class) using the mousewheel, it shows a very strange and ugly effect.
It seems the contents are scrolled the wrong way initially.


This is caused by Windows on owner-drawn listboxes when the setting for "Smooth-scroll list boxes" is enabled in the performance options.


SmoothScrollingSystemSetting.png


One way to fix it is to disable this setting, but this is a system wide setting.
Normally it is not a very good idea to fix those issues by having the user to change system wide settings.


Better to fix in our application. To do this we need to override the default Windows behavior and implement custom code to scroll the contents.
This is done by catching the WM_MOUSEWHEEL message, process the data which is passed and perform the scroll by sending WM_VSCROLL to the listbox.


SalExtension library already offers a function to do this.
The sample for this article uses an adapted version, named PALScrollOnWheel
Using this function you can specify how many lines will be scrolled on one wheel-tick:

List Box: lbOutline
   Message Actions
      On WM_MOUSEWHEEL
         Call PALScrollOnWheel( hWndItem, wParam, nLinesPerTick )
         Return 0


To see the issue and the workaround, have a look at this YouTube video:

Video.png cOutlineListbox : ugly mousewheel scrolling (and workaround)


Here you can download the sample:
Down.png WIKI_cOutlineListboxScrollFix.zip