1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
unit MyDBNavigator;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, DbCtrls,db,LCLStrConsts;
type
TMyDBNavigator = class(TDBNavigator)
private
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
procedure BtnClick(Index: TNavigateBtn); override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure TMyDBNavigator.BtnClick(Index: TNavigateBtn);
begin
//inherited BtnClick(Index);
if (DataSource<>nil) and (DataSource.State<>dsInactive) then begin
if not (csDesigning in ComponentState) and Assigned(BeforeAction) then
BeforeAction(Self,Index);
with DataSource.DataSet do begin
case Index of
nbPrior: begin Prior; showmessage('coucou'); end;
nbNext: Next;
nbFirst: begin First; showmessage('coucou'); end;
nbLast: Last;
nbInsert: Insert;
nbEdit: Edit;
nbCancel: Cancel;
nbPost: Post;
nbRefresh: Refresh;
nbDelete:
if (not ConfirmDelete)
or (MessageDlg(rsDeleteRecord, mtConfirmation, mbOKCancel, 0 )<>
mrCancel)
then
Delete;
end;
end;
end;
if not (csDesigning in ComponentState) and Assigned(OnClick) then
OnClick(Self,Index);
end;
procedure Register;
begin
{$I mydbnavigator_icon.lrs}
RegisterComponents('Data Controls',[TMyDBNavigator]);
end;
end. |
Partager