From: RaNo on
Hi,

WM 6.5 has introduced whole-clientarea drag scrolling of various UI
elements with side scrollbars. I'd like to disable this feature for a
given listbox in my app. This interferes with the drag&drop
functionality that I implemented in this listbox.

How to disable this new feature in WM 6.5?
From: Christopher Fairbairn [MVP] on
Hi,

"RaNo" <google(a)ranosoft.net> wrote in message
news:ae2ce1be-55aa-4674-9ba0-47adbf0e4af0(a)j39g2000yqh.googlegroups.com...
> WM 6.5 has introduced whole-clientarea drag scrolling of various UI
> elements with side scrollbars. I'd like to disable this feature for a
> given listbox in my app. This interferes with the drag&drop
> functionality that I implemented in this listbox.

I did a little digging through the MSDN documentation
(http://msdn.microsoft.com/en-us/library/ee220935.aspx etc) and couldn't
find a window style or similiar feature that could programatically toggle
this functionality on and off cleanly. It may exist, but I couldn't find
it..

The best approach I am aware of at present is to subclass the window
procedure of the listbox and make it ignore any WM_GESTURE window messages
it receives by sending them directly to the default window procedure.

For example within a native C or C++ application you could use the following
source code (assuming hWndList is the HWND of your listbox).

#include <gesture.h>

LRESULT CALLBACK DisableAutoScrollWindowProc(HWND hWnd, UINT message, WPARAM
wParam, LPARAM lParam)
{
WNDPROC oldProc = (WNDPROC)GetWindowLong(hWnd, GWL_USERDATA);
if (message == WM_GESTURE)
return DefWindowProc(hWnd, message, wParam, lParam);
else
return CallWindowProc(oldProc, hWnd, message, wParam, lParam);
}

// This will hook up the new window procedure, call this from within
WM_CREATE or WM_INITDIALOG etc
SetWindowLong(hWndList, GWL_USERDATA, GetWindowLong(hWndList, GWL_WNDPROC));
SetWindowLong(hWndList, GWL_WNDPROC, (LONG)DisableAutoScrollWindowProc);

If you are developing for the .NET CF, you could also use this technique.
Take a look at an article such as "How to: Use a Class for Hooking Windows
Procedures" - http://msdn.microsoft.com/en-us/library/ms229658.aspx - to
determine how this could be converted into a couple of P/Invoke calls.

Hope this helps,
Christopher Fairbairn