Add mouse scroll events to DBGRID

xiaoxiao2021-03-06  53

Unit unit1;

Interface

Uses

Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, AdoDB, Grids, DBGRIDS

Type

TFORM1 = Class (TFORM)

DBGRID1: TDBGRID;

ADOTABLE1: TADOTABLE;

DataSource1: TDataSource;

Procedure formcreate (Sender: TOBJECT);

Private

Procedure onmousewheel (var Msg: TMSG; VAR HANDED: BOOLEAN);

{Private Declarations}

public

{Public declarations}

END;

VAR

FORM1: TFORM1;

IMPLEMENTATION

{$ R * .dfm}

/ / -------------------------------------------------------------------------------------------- ------------------------------

Procedure TFORM1.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); end else begin if DBGrid1.Focused then SendMessage (DBGrid1.Handle, WM_VSCROLL, SB_PAGEDOWN, 0); END; Handled: = true;

END;

Procedure TFORM1.FormCreate (Sender: TOBJECT);

Begin

Application.onMessage: = onmousewheel; // Intercept mouse scroll END;

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

New Post(0)