İnternette komponentlara baktığımda DataAware BitButton gibi, yani Veri Tabanı Duyarlı Buton ile karşılaştım.

Acaba bunların kullanım alanları nasıl olabilir?
Çok gerekli midir ?
Saygılar
Oğuz ÖZTÜRK
Kod: Tümünü seç
//Original freeware source by Waheed Al-Sayer, 1997
//Modifications by U. Molzahn, 1997/2000 Freeware, but no warranty whatsoever !
unit dpDBSpeedButton;
interface
uses
{$ifdef WIN32}
ComCtrls, CommCtrl,
{$endif}
WinTypes, WinProcs, Messages, SysUtils, Classes,
Graphics, Controls, StdCtrls, DB, DbTables, DBCtrls, Buttons;
type
TdpDBSpeedButton = class(TSpeedButton)
private
{ Private declarations }
fDataLink: TFieldDataLink;
FReverseLogic: Boolean;
function GetDataField: string;
function GetDataSource: TDataSource;
procedure SetDataField(const Field: string);
procedure SetDataSource(DataSource: TDataSource);
procedure DataChange(Sender: TObject);
procedure Notification(Component: TComponent; Operation: TOperation); override;
{$ifndef VER80}
procedure CmGetDataLink(var Msg: TMessage); message Cm_GetDataLink;
{$endif}
procedure SetReverseLogic(Value: boolean);
protected
public
constructor Create(Owner: TComponent); override;
destructor Destroy; override;
published
property DataField: string read GetDataField write SetDataField;
property DataSource: TDataSource read GetDataSource write SetDataSource;
property ReverseLogic: Boolean read FReverseLogic write SetReverseLogic;
end;
procedure Register;
implementation
constructor TdpDBSpeedButton.Create(Owner: TComponent);
begin
inherited Create(Owner);
FDataLink := TFieldDataLink.Create;
FDataLink.OnDataChange := DataChange;
FDataLink.Control := Self;
FReverseLogic := True;
end;
destructor TdpDBSpeedButton.Destroy;
begin
FDataLink.Free;
inherited Destroy;
end;
procedure TdpDBSpeedButton.SetReverseLogic(Value: boolean);
begin
if Value <> FReverseLogic then begin
FReverseLogic := Value;
DataChange(Self);
end;
end;
function TdpDBSpeedButton.GetDataField: string;
begin
Result := FDataLink.FieldName
end;
function TdpDBSpeedButton.GetDataSource: TDataSource;
begin
Result := FDataLink.DataSource
end;
procedure TdpDBSpeedButton.SetDataField(const Field: string);
begin
fDataLink.FieldName := Field
end;
procedure TdpDBSpeedButton.SetDataSource(DataSource: TDataSource);
begin
fDataLink.DataSource := DataSource;
{$ifndef VER80}
if DataSource <> nil then
DataSource.FreeNotification(Self);
{$endif}
end;
procedure TdpDBSpeedButton.Notification(Component: TComponent; Operation: TOperation);
begin
inherited Notification(Component, Operation);
if (fDataLink <> nil) and (Component = DataSource) and (Operation = opRemove)
then
DataSource := nil
end;
procedure TdpDBSpeedButton.DataChange(Sender: TObject);
begin
if fDataLink.Field = nil then
else if FReverseLogic then
if FDataLink.Field.DisplayText = 'True' then
Enabled := False
else if FDataLink.Field.DisplayText = 'False' then
Enabled := True
else Enabled := FDataLink.Field.DisplayText = ''
else if FDataLink.Field.DisplayText = 'True' then
Enabled := True
else if FDataLink.Field.DisplayText = 'False' then
Enabled := False
else Enabled := FDataLink.Field.DisplayText <> ''
end;
{$ifndef VER80}
procedure TdpDBSpeedButton.CmGetDataLink(var Msg: TMessage);
begin
Msg.Result := LongInt(fDataLink);
end;
{$endif}
procedure Register;
begin
RegisterComponents('Data Controls', [TdpDBSpeedButton]);
end;
end.