Modificar uma propriedade
Estou tentado adicionar um editor a propriedade caption do label. Estou fazendo isso somente para estudo.
Segue o código:
e para registrar
Só que não acontece nada... eu fiz o mesmo para o ClientDataSet e funcionou mudando o TCustomLabel para TClientDataSet.
O que pode estar errado? Lembrando que eu estou utilizando o Delphi 2007
Desde já agradeço
Segue o código:
unit uStringProperty;
interface
uses
DesignEditors, DesignIntf, SysUtils, Dialogs, StdCtrls;
type
TStringProperty = class(TPropertyEditor)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure Edit; override;
procedure SetValue(const Value: string); override;
end;
implementation
uses
uFrmEditor, Controls;
{ TEditorSqlProperty }
procedure TStringProperty.Edit;
begin
inherited Edit;
with GetComponent(0) as TCustomLabel do
with TFrmEditor.Create(nil) do
try
mmEditor.Lines.Text := Caption;
ShowModal;
if ModalResult = mrOk then
begin
Caption := mmEditor.Lines.Text;
end;
finally
Free;
end;
end;
function TStringProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TStringProperty.GetValue: string;
begin
Result := (GetComponent(0) as TCustomLabel).Caption;
end;
procedure TStringProperty.SetValue(const Value: string);
begin
if Trim(Value) = (GetComponent(0) as TCustomLabel).Caption then
Exit;
TCustomLabel(GetComponent(0)).Caption := Trim(Value);
Designer.Modified;
end;
end.
e para registrar
RegisterPropertyEditor(TypeInfo(String), TCustomControl, ´Caption´, TStringProperty);
Só que não acontece nada... eu fiz o mesmo para o ClientDataSet e funcionou mudando o TCustomLabel para TClientDataSet.
O que pode estar errado? Lembrando que eu estou utilizando o Delphi 2007
Desde já agradeço
Marcelo.mileris
Curtidas 0