Example Delphi
Delphi Examples Collection
Today, Delphi is one of the popular desktop programming tool. There are thousand even million programmer in this world using delphi as their favorit tool. This site try to collect the examples, tips and tricks of Delphi programming. We collect, test them and redistribute the collection of delphi programming for you.
Mouse Scroll Within DBGrid
Author: admin | Category: Database, Tips and Tricks
//This is how we can make our DBGrid change the focus to previous or next record by scrolling mouse //In this example we use an ADOTable, a Datasource and a DBGrid unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids, DBGrids, ExtCtrls, DB, ADODB; type TForm1 = class(TForm) DataSource1: TDataSource; ADOTable1: TADOTable; DBGrid1: TDBGrid; procedure FormCreate(Sender: TObject); private { Private declarations } OldGridProc: TWndMethod; procedure GridWindowProc(var Message: TMessage); public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin ADOTable1.Active:=True; OldGridProc := DBGrid1.WindowProc; DBGrid1.WindowProc := GridWindowProc; end; procedure TForm1.GridWindowProc(var Message: TMessage); var Pos: SmallInt; begin OldGridProc(Message); if Message.Msg = WM_VSCROLL then //or WM_HSCROLL begin Pos := Message.WParamHi; //Scrollbox position ADOTable1.RecNo := Pos; end; end; end.
Post Meta
-
Database, Tips and Tricks -
Comments Feed -