.net - Make mouse tilt horizontal scrolling always repeat -
i'm designing form horizontal scroll bar docked @ bottom. wanted add support side-scrolling using mouse tilt buttons , found this solution which, after bit of tinkering, seemed trick – is, while form had gdi graphics drawn on surface.
however, since i've added controls form , found when mouse on of them tilt operation fires once-at-a-time instead of repeatedly when mouse on other part of form.
to see mean (if have mouse tilt buttons) dock horizontal scrollbar onto bottom of form, add few other controls , paste in code:
public class form1 const wm_mousehwheel integer = &h20e protected overrides sub wndproc(byref m message) mybase.wndproc(m) if me.isdisposed orelse m.hwnd <> me.handle return select case m.msg case wm_mousehwheel hscrollbar1 if ctype(m.wparam, integer) < 0 '______________ left scroll if .value > 0 .value -= 1 else '______________________________________________ right scroll if .value < (.maximum - .largechange + 1) .value += 1 end if end m.result = ctype(1, intptr) 'indicates message has been handled end select end sub private sub hscrollbar1_valuechanged(sender object, e system.eventargs) handles hscrollbar1.valuechanged console.writeline(hscrollbar1.value) end sub end class
you'll see side-scrolling repeats when mouse on blank part of form, "one-shots" when it's on control.
i'm guessing solution lies somewhere in message's .result
value, i'm @ loss should be. in fact i'm not sure i'm returning correct value anyway because code in original solution threw exception directcast function swapped ctype, seemed work okay. i've tried working out using spy++ can't see obvious.
any ideas please?
update
i've noticed when include 'child' windows in spy++ there 2 (0x020e) messages , 2 return values, 1 0. presume message being passed onto control form. guess question is: can message prevented being passed control? or can control's return value intercepted , converted 1?
i've managed contrive workaround feel sure there must better method this. i've done add class each type of control used on form , inheriting control. i've added wndproc procedure each class 1
returned wm_mousehwheel
messages processed these controls. example, button class:
public class scbutton inherits button protected overrides sub wndproc(byref m message) mybase.wndproc(m) if me.isdisposed orelse m.hwnd <> me.handle return if m.msg = win32messages.wm_mousehwheel m.result = new intptr(1) end sub end class
then matter of changing references in form's designer code.
as say, i'm sure there must better method this. painful if had large number of different control classes, in case needed few basic controls.
i left open few days in hope suggest better solution nothing has been forthcoming i'm going accept own answer.
Comments
Post a Comment