Datagrid Scrollbar Capture

  • Thread starter Thread starter jon morgan
  • Start date Start date
J

jon morgan

Hi,

How do I stop the datagrid's vscrollbar from capturing mousewheel messages?
Seems they don't reach the grid's wndproc -where are they handled ? I need
to use the wheel to increment values in grid cells.

Thanks for your help

Jon
 
Well I figured out how to do this. It's necessary to hook the mouse using
the SetWindowsHookEx function. The details are explained in Stephen
Teilhets' excellent book, SubClassing and Hooking with Visual Basic (ch13,
pp 363-4). This method hooks the mouse at low level and by listening for
mouse wheel messages and not passing them on (just return any positive
value), the grid scrollbar doesn't get a look in. Remember to unhook the
mouse when you're finished with it though as otherwise you'll bring back
fond memories of the blue screen of death...

Jon
 
The mouse messages don't get to the datagrid because they get to the
scrollbar control(s) it contains; you could iterate the datagrid's Controls
collection and get to them. BTW, instead of using a windows hook, you might
be able to use Application.AddMessageFilter.
 
Thanks Andrew I'll check out the AddMessageFilter option - the hook is a
rather blunt if satisfying weapon.
 
Back
Top