如何在系统级禁止鼠标滚轮功能?(100分)

  • 主题发起人 主题发起人 GZCYP
  • 开始时间 开始时间
G

GZCYP

Unregistered / Unconfirmed
GUEST, unregistred user!
如题。先谢了各位。
 
问题: 怎样捕捉鼠标滚轮的事件? ( 积分: 50 ) &nbsp;<br>分类: 数据库-C/S型 &nbsp;<br> <br>来自: fdluoping, 时间: 2005-12-27 9:27:00, ID: 3309653 &nbsp;<br>我的程序里有个DBGRID,我想在鼠标滚轮的事件里写代码,有哪位大哥知道.请告知. <br> <br>来自: cracy, 时间: 2005-12-27 9:30:00, ID: 3309659 &nbsp;<br>试下捕捉 WM_MOUSEWHEEL 消息。 <br>下面是在DELPHI帮助中在SDK找到的帮助说明 <br>[New - Windows NT] <br><br>The WM_MOUSEWHEEL message is sent to the focus window when the mouse wheel is rotated. The DefWindowProc function propagates the message to the window's parent. There should be no internal forwarding of the message, since DefWindowProc propagates it up the parent chain until it finds a window that processes it. <br><br>WM_MOUSEWHEEL <br>fwKeys = LOWORD(wParam); &nbsp; &nbsp;// key flags <br>zDelta = (short) HIWORD(wParam); &nbsp; &nbsp;// wheel rotation <br>xPos = (short) LOWORD(lParam); &nbsp; &nbsp;// horizontal position of pointer <br>yPos = (short) HIWORD(lParam); &nbsp; &nbsp;// vertical position of pointer <br><br><br>Parameters <br><br>fwKeys <br><br>Value of the low-order word of wParam. Indicates whether various virtual keys are down. This parameter can be any combination of the following values: <br><br>Value Description <br>MK_CONTROL Set if the CTRL key is down. <br>MK_LBUTTON Set if the left mouse button is down. <br>MK_MBUTTON Set if the middle mouse button is down. <br>MK_RBUTTON Set if the right mouse button is down. <br>MK_SHIFT Set if the SHIFT key is down. <br><br><br>zDelta <br><br>The value of the high-order word of wParam. Indicates the distance that the wheel is rotated, expressed in multiples or divisions of WHEEL_DELTA, which is 120. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. <br><br>xPos <br><br>Value of the low-order word of lParam. Specifies the x-coordinate of the pointer, relative to the upper-left corner of the screen. <br><br>yPos <br><br>Value of the high-order word of lParam. Specifies the y-coordinate of the pointer, relative to the upper-left corner of the screen. <br><br><br><br>Remarks <br><br>The zDelta parameter will be a multiple of WHEEL_DELTA, which is set at 120. This is the threshold for action to be taken, and one such action (for example, scrolling one increment) should occur for each delta. <br>The delta was set to 120 to allow Microsoft or other vendors to build finer-resolution wheels in the future, including perhaps a freely-rotating wheel with no notches. The expectation is that such a device would send more messages per rotation, but with a smaller value in each message. To support this possibility, you should either add the incoming delta values until WHEEL_DELTA is reached (so for a given delta-rotation you get the same response), or scroll partial lines in response to the more frequent messages. You could also choose your scroll granularity and accumulate deltas until it is reached. <br> <br>来自: bbscom, 时间: 2005-12-27 9:56:33, ID: 3309725 &nbsp;<br>是在數據集裡: <br>procedure TForm1.ADOTable1BeforeScroll(DataSet: TDataSet); <br>begin <br> ... ... <br>end; <br><br>procedure TForm1.ADOTable1AfterScroll(DataSet: TDataSet); <br>begin <br> ... ... <br>end; <br> <br>来自: fdluoping, 时间: 2005-12-27 10:41:45, ID: 3309818 &nbsp;<br>ADOTable1BeforeScroll,ADOTable1AfterScroll 我都试过了,但是键盘上的上下键好用,鼠标滚轮不好用。WM_MOUSEWHEEL具体怎么使用,能不能给个例子?麻烦了。 <br> <br>来自: Beyondbill, 时间: 2005-12-27 10:58:22, ID: 3309832 &nbsp;<br>需要自己从TCustomDBGrid中继续再处理OnMouseWheel, OnMouseWheelDown, OnMouseWheelUp事件 <br><br>以下为简单的实现 <br>procedure TMyDBGrid.OnMouseWheelDown(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean) <br>begin <br> Self.DataSource.DataSet.Next; <br>end; <br><br>procedure TMyDBGrid.OnMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean) <br>begin <br> Self.DataSource.DataSet.Piror; <br>end; <br> <br>来自: 寻路, 时间: 2005-12-27 10:57:14, ID: 3309833 &nbsp;<br>定义: <br>procedure OnMouseWheel(var Msg :TMsg;var Handled:Boolean); <br>初始化: <br>Application.OnMessage := OnMouseWheel; // 截获鼠标滚动事件 <br>实现: <br>procedure TfrmMain.OnMouseWheel(var Msg: TMsg; var Handled: Boolean); <br>begin <br> if Msg.message = WM_MouseWheel then <br> begin <br> &nbsp; if Msg.wParam &gt; 0 then <br> &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp;if DBGrid.Focused then <br> &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(DBGrid.Handle, WM_VSCROLL, SB_PAGEUP, 0); <br> &nbsp; &nbsp;end <br> &nbsp; else <br> &nbsp; &nbsp;begin <br> &nbsp; &nbsp; &nbsp;if DBGrid.Focused then <br> &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(DBGrid.Handle, WM_VSCROLL, SB_PAGEDOWN, 0); <br> &nbsp; &nbsp;end; <br> &nbsp; Handled:= True; <br> end; <br>end; <br> <br>来自: fdluoping, 时间: 2005-12-27 19:46:44, ID: 3310643 &nbsp;<br>TCustomDBGrid 是什么控件?Delphi7里我怎么没有看到。我用的是DBGrid控件。 <br><br>单独写个过程,调用方法能不能说下。 <br> <br>来自: zqw0117, 时间: 2005-12-27 19:54:06, ID: 3310646 &nbsp;<br>TDBGrid继承自TCustomDBGrid类哈!fdluoping兄看来不太了解VCL的架构:) <br> <br>来自: 寻路, 时间: 2005-12-28 9:19:28, ID: 3310969 &nbsp;<br>做控件比较好的做法是从Custom开始,如:TCustomDBGrid 和 TDBGrid,那应该从TCustomDBGrid! <br> <br>来自: fdluoping, 时间: 2005-12-28 9:21:01, ID: 3310974 &nbsp;<br>多人接受答案了。 <br> <br>得分大富翁: bbscom-10,Beyondbill-10,cracy-10,zqw0117-10,寻路-10,
 
我想要的不是在一个应用程序中捕捉鼠标滚轮消息从而来禁止鼠标滚轮,我希望在windows系统中禁止鼠标滚轮,也就是说退出关闭应用程序后禁止鼠标滚轮仍然有效。<br>我想应该是用某个API函数来处理的,但我没有查到,请各位帮忙。
 
那就用hook吧,
 
这么复杂,买一个不带滚轮的鼠标不就行了
 
应用程序很难做到退出关闭应用程序后禁止鼠标滚轮仍然有效。<br> &nbsp;1.修改注册表,不知有没有这样的。<br> &nbsp;2.用HOOK应该可以的
 
多人接受答案了。
 
后退
顶部