Добавление свойсва у движка
Значит хочу свой движок сделать - вот описание
unit frxCDSComponents;
interface
uses
Classes, frxClass, frxCustomDB, DB, DBClient, frxDsgnIntf, frxCDSEditor;
type
TfrxClientDataSet = class(TfrxCustomQuery)
private
FClientDataSet: TClientDataSet;
SQL: TStrings;
protected
procedure SetSQL(Value: TStrings); override;
function GetSQL: TStrings; override;
procedure OnChangeSQL(Sender: TObject); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
class function GetDescription: String; override;
property ClientDataSet: TClientDataSet read FClientDataSet;
published
property EditFields: Booleab
end;
implementation
{ TfrxClientDataSet }
constructor TfrxClientDataSet.Create(AOwner: TComponent);
begin
FClientDataSet := TClientDataSet.Create(nil);
DataSet := FClientDataSet;
SQL := TStringList.Create;
inherited;
end;
destructor TfrxClientDataSet.Destroy;
begin
SQL.Free;
inherited;
end; {End TfrxClientDataSet.Destroy}
class function TfrxClientDataSet.GetDescription: String;
begin
Result := 'ClientDataSet';
end; {End TfrxClientDataSet.GetDescription}
procedure TfrxClientDataSet.SetSQL(Value: TStrings);
begin
SQL := Value;
end; {End TfrxClientDataSet.SetSQL}
function TfrxClientDataSet.GetSQL: TStrings;
begin
Result := SQL;
end; {End TfrxClientDataSet.GetSQL}
procedure TfrxClientDataSet.OnChangeSQL(Sender: TObject);
begin
FClientDataSet.CommandText := FClientDataSet.Params.ParseSQL(SQL.Text, True);
inherited;
end; {End TfrxClientDataSet.OnChangeSQL}
procedure TfrxClientDataSet.Notification(AComponent: TComponent;
Operation: TOperation);
begin
if (Operation = opInsert) and not FClientDataSet.Active then
begin
with FClientDataSet do
begin
with FieldDefs.AddFieldDef do
begin
Name := 'NEW';
DataType := ftString;
Size := 15;
end;
CreateDataSet;
end;
end;
inherited;
end; {End TfrxClientDataSet.Notification}
initialization
frxObjects.RegisterObject1(TfrxClientDataSet, nil, '', 'BDE', 0, 39);
end.
// ============================================
К нему хочу сделать редактор полей (уже готов , только прикрутить), вот как свойство описываю
unit frxCDSEditor;
interface
uses
Classes, Dialogs;
implementation
uses
frxDsgnIntf, frxCDSComponents;
type
TfrxFieldsProperty = class(TfrxClassProperty)
public
function GetAttributes: TfrxPropertyAttributes; override;
function Edit: Boolean; override;
end;
{ TfrxFieldsProperty }
function TfrxFieldsProperty.Edit: Boolean;
begin
ShowMEssage('sdsd');
Result := True;
end; {TfrxFieldsProperty.Edit}
function TfrxFieldsProperty.GetAttributes: TfrxPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end; {End TfrxFieldsProperty.GetAttributes}
initialization
frxPropertyEditors.Register(TypeInfo(TStrings), TfrxClientDataSet, 'EditFields',
TfrxFieldsProperty);
end.
...............................
Но чего то не хватает , так как этого свойства у объекта не видно
unit frxCDSComponents;
interface
uses
Classes, frxClass, frxCustomDB, DB, DBClient, frxDsgnIntf, frxCDSEditor;
type
TfrxClientDataSet = class(TfrxCustomQuery)
private
FClientDataSet: TClientDataSet;
SQL: TStrings;
protected
procedure SetSQL(Value: TStrings); override;
function GetSQL: TStrings; override;
procedure OnChangeSQL(Sender: TObject); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
class function GetDescription: String; override;
property ClientDataSet: TClientDataSet read FClientDataSet;
published
property EditFields: Booleab
end;
implementation
{ TfrxClientDataSet }
constructor TfrxClientDataSet.Create(AOwner: TComponent);
begin
FClientDataSet := TClientDataSet.Create(nil);
DataSet := FClientDataSet;
SQL := TStringList.Create;
inherited;
end;
destructor TfrxClientDataSet.Destroy;
begin
SQL.Free;
inherited;
end; {End TfrxClientDataSet.Destroy}
class function TfrxClientDataSet.GetDescription: String;
begin
Result := 'ClientDataSet';
end; {End TfrxClientDataSet.GetDescription}
procedure TfrxClientDataSet.SetSQL(Value: TStrings);
begin
SQL := Value;
end; {End TfrxClientDataSet.SetSQL}
function TfrxClientDataSet.GetSQL: TStrings;
begin
Result := SQL;
end; {End TfrxClientDataSet.GetSQL}
procedure TfrxClientDataSet.OnChangeSQL(Sender: TObject);
begin
FClientDataSet.CommandText := FClientDataSet.Params.ParseSQL(SQL.Text, True);
inherited;
end; {End TfrxClientDataSet.OnChangeSQL}
procedure TfrxClientDataSet.Notification(AComponent: TComponent;
Operation: TOperation);
begin
if (Operation = opInsert) and not FClientDataSet.Active then
begin
with FClientDataSet do
begin
with FieldDefs.AddFieldDef do
begin
Name := 'NEW';
DataType := ftString;
Size := 15;
end;
CreateDataSet;
end;
end;
inherited;
end; {End TfrxClientDataSet.Notification}
initialization
frxObjects.RegisterObject1(TfrxClientDataSet, nil, '', 'BDE', 0, 39);
end.
// ============================================
К нему хочу сделать редактор полей (уже готов , только прикрутить), вот как свойство описываю
unit frxCDSEditor;
interface
uses
Classes, Dialogs;
implementation
uses
frxDsgnIntf, frxCDSComponents;
type
TfrxFieldsProperty = class(TfrxClassProperty)
public
function GetAttributes: TfrxPropertyAttributes; override;
function Edit: Boolean; override;
end;
{ TfrxFieldsProperty }
function TfrxFieldsProperty.Edit: Boolean;
begin
ShowMEssage('sdsd');
Result := True;
end; {TfrxFieldsProperty.Edit}
function TfrxFieldsProperty.GetAttributes: TfrxPropertyAttributes;
begin
Result := [paDialog, paReadOnly];
end; {End TfrxFieldsProperty.GetAttributes}
initialization
frxPropertyEditors.Register(TypeInfo(TStrings), TfrxClientDataSet, 'EditFields',
TfrxFieldsProperty);
end.
...............................
Но чего то не хватает , так как этого свойства у объекта не видно
Комментарии