delphi 自定义控件EDIT内容改变事件
unit AntiEdit;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls,ExtCtrls,
Graphics,DBGrids, DB, ADODB,Dialogs;
type
TAntiEdit = class(TEdit)
private
{ Private declarations }
FTimer:TTimer;
FInterval:Integer;
FDBGrid:TDBGrid;
FDataSource:TDataSource;
FQury:TADOQuery;
FConnection:TADOConnection;
FSQLSelect:String;
FColumn:Integer; //返回第几栏
FValue:String;
FOnChange:TNotifyEvent;
procedure MoveShow(Sender:TObject);
procedure SetConnection(const Value:TADOConnection );
procedure SetSQLSelect(const Value: string);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner:TComponent);
destructor Destroy;
procedure StartAni;
procedure StopAni;
procedure WMChange(var message:TMessage);message WM_SETTEXT; //改变事没有反应
property Interval:Integer read FInterval write FInterval;
property Connection:TADOConnection read FConnection write SetConnection;
property SQLSelect :string read FSQLSelect write SetSQLSelect;
published
{ Published declarations }
end;
//procedure Register;
implementation
//procedure Register;
//begin
// RegisterComponents('Samples', [TAntiEdit]);
//end;
{ TAntiEdit }
constructor TAntiEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
color:=clBlack;
font.Color:=clWhite;
font.Size:=12;
font.Name:='GB2312';
// FDBGrid.DataSource:=FDataSource;
FDBGrid:=TDBGrid.Create(nil);
FQury:=TADOQuery.Create(nil);
FQury.Connection:=FConnection;
FDataSource:=TDataSource.Create(nil);
FDataSource.DataSet:=FQury;
// FDBGrid.DataSource:=
// Update;
// self.Repaint;
// self.Invalidate
// FTimer:=TTimer.Create(self);
// FTimer.Enabled:=False;
// FTimer.OnTimer:=MoveShow;
// FInterval:=1000;
end;
destructor TAntiEdit.Destroy;
begin
FDBGrid.Free;
FDataSource.Free;
FQury.Free;
end;
procedure TAntiEdit.MoveShow(Sender: TObject);
begin
//dadd
end;
procedure TAntiEdit.SetConnection(const Value: TADOConnection);
begin
FConnection:=Value;
end;
procedure TAntiEdit.SetSQLSelect(const Value: string);
begin
FSQLSelect := Value;
end;
procedure TAntiEdit.StartAni;
begin
FTimer.Interval:=FInterval;
FTimer.Enabled:=True;
end;
procedure TAntiEdit.StopAni;
begin
FTimer.Enabled:=False;
end;
procedure TAntiEdit.WMChange(var message: TMessage);
begin
{
FDBGrid.DataSource:= FDataSource;
FQury.Close;
FQury.SQL.Clear;
FQury.SQL.Text:=FSQLSelect;
FQury.Open;
FDBGrid.Parent:=self;
}
Showmessage('ok');
//改变事没有反应 好像有触发
end;
end.