VT OutlineListbox control
cOutlineListBox: workaround for the ugly mousewheel-scroll visual effect
When scrolling the contents of cOutlineListbox 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.
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:
Here you can download the sample: