以下程式放在乙個公共模組中,
在窗體中的form_load事件中 寫 hookwheel me.hwnd
在窗體中的form_unload事件中 寫 unhookwheel me.hwnd
在**的gotfocus事件中 set ctlwheel=msflexgrid1'( **名稱,根據具體情況,修改這個名稱)
在**的lostfocus事件中 set ctlwheel=nothing'( **名稱,根據具體情況,修改這個名稱)
option explicit
private declare function setwindowlong lib "user32" alias "setwindowlonga" (byval hwnd as long, byval nindex as long, byval dwnewlong as long) as long
private declare function callwindowproc lib "user32" alias "callwindowproca" (byval lpprevwndfunc as long, byval hwnd as long, byval msg as long, byval wparam as long, byval lparam as long) as long
private const gwl_wndproc as long = (-4)
private const wm_mousewheel as long = &h20a
private m_oldwindowproc as long
public ctlwheel as object
public sub hookwheel(byval frmhwnd)
m_oldwindowproc = setwindowlong(frmhwnd, gwl_wndproc, addressof pvwindowproc)
end sub
public sub unhookwheel(byval hwnd as long)
dim lngreturnvalue as long
lngreturnvalue = setwindowlong(hwnd, gwl_wndproc, m_oldwindowproc)
end sub
private function pvwindowproc(byval hwnd as long, byval wmsg as long, byval wparam as long, byval lparam as long) as long
on error goto errh
select case wmsg
case wm_mousewheel
if not ctlwheel is nothing then
if typeof ctlwheel is msflexgrid then
with ctlwheel
select case wparam
case is > 0
if ctlwheel.toprow > 0 then
ctlwheel.toprow = ctlwheel.toprow - 1
end if
case else
ctlwheel.toprow = ctlwheel.toprow + 1
end select
end with
end if
end if
end select
errh:
pvwindowproc = callwindowproc(m_oldwindowproc, hwnd, wmsg, wparam, lparam)
end function
javascript基礎四 (事件應用滑鼠滾輪)
var odiv document.getelementbyid div ie chrome onmousewheel event.wheeldelta 上 120 下 120 firefox dommousescroll 必須用addeventlistener event.detail 阻止當前事...
Silverlight4Beta之滑鼠滾輪支援增強
滑鼠滾輪支援在sl3中就出現了,所有的uielement都提供mousewheel事件,然後我們可以通過mousewheeleventargs中的相關引數處理滾輪觸發時的具體細節 maxthon中滾輪一直不可用,據說ff也不可用 很強大,而且看上去這沒什麼問題。不過一到實際專案中我們就會發現這裡有一...
Silverlight4Beta之滑鼠滾輪支援增強
滑鼠滾輪支援在sl3中就出現了,所有的uielement都提供mousewheel事件,然後我們可以通過mousewheeleventargs中的相關引數處理滾輪觸發時的具體細節 maxthon中滾輪一直不可用,據說ff也不可用 很強大,而且看上去這沒什麼問題。不過一到實際專案中我們就會發現這裡有一...