Delphi Development: Rolling records with mouse scroll with mouse in dbgrid

xiaoxiao2021-04-09  503

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?

转载请注明原文地址:https://www.9cbs.com/read-133046.html

New Post(0)