First write a process onMousewheel in the Unit's private. As follows: private {private declarations} procated {private declarations} procedure onmousewheel (var Msg: tmsg; var handled: boolean);
The code that implements the onmousewheell process is as follows:
Procedure TDeptfrm.OnMouseWheel (Var Msg: TMsg; var Handled: Boolean); begin if Msg.message = WM_MouseWheel then begin if Msg.wParam> 0 then begin if DBGrid1.Focused then SendMessage (DBGrid1.Handle, WM_VSCROLL, SB_PAGEUP, 0) ELSE BEGIN if DBGRID1.FOCUSED THEN SENDMESSAGE (DBGRID1.Handle, WM_VScroll, SB_PAGEDOWN, 0); END;
The above code needs to change DBGRID1 for the DBGRID you named.
Finally, call the above method in FormCreate
Procedure tdeptfrm.formcreate (sender: TOBJECT); Begin Application.onMessage: = OnMousewheel; End;
Complete the above operation, then run your program, see if the result is right?