燕
燕岛秋潮
Unregistered / Unconfirmed
GUEST, unregistred user!
我在开发控件的属性编辑器的时候,遇到一个问题,如果在form上放置多个相同的控件,在
变化一个控件时,其余的几个也同样跟着变化,不能独立设置!请各位指点!
具体的实例如下:
unit ssTest;
interface
uses
Windows, Messages, SysUtils, Classes,DesignEditors,DesignIntf;
type TCataProperty = class(TPropertyEditor)
public
function GetAttributes:TPropertyAttributes;override;
function GetValue:string;override;
procedure SetValue(const Value:String);override;
procedure GetValues (proc:TGetStrProc);override;
end;
type
TssTest = class(Tcomponent)
private
{ Private declarations }
FCataProperty : string;
function GetCatlaog:string;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Catalog:string read GetCatlaog write FCataProperty stored true;
end;
procedure Register;
implementation
var
CName:string;
procedure Register;
begin
RegisterComponents('HDC4', [TssTest]);
RegisterPropertyEditor(TypeInfo(string),TssTest,'Catalog',TCataProperty);
end;
{ TCataProperty }
function TCataProperty.GetAttributes: TPropertyAttributes;
begin
result := [paValueList];
end;
function TCataProperty.GetValue: string;
begin
result := CName;
end;
procedure TCataProperty.GetValues(proc: TGetStrProc);
var
i:integer; st:TStringList;
begin
//st := TStringList.Create;
//for i:=0 to 4 do
// st.Add(inttostr(i));
for i:=0 to 4 do
begin
proc (inttostr(i));
end;
end;
procedure TCataProperty.SetValue(const Value:String);
begin
CName := Value;
end;
{ TssTest }
function TssTest.GetCatlaog: string;
begin
result := CName;
FCataProperty:= CName;
end;
end.
变化一个控件时,其余的几个也同样跟着变化,不能独立设置!请各位指点!
具体的实例如下:
unit ssTest;
interface
uses
Windows, Messages, SysUtils, Classes,DesignEditors,DesignIntf;
type TCataProperty = class(TPropertyEditor)
public
function GetAttributes:TPropertyAttributes;override;
function GetValue:string;override;
procedure SetValue(const Value:String);override;
procedure GetValues (proc:TGetStrProc);override;
end;
type
TssTest = class(Tcomponent)
private
{ Private declarations }
FCataProperty : string;
function GetCatlaog:string;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Catalog:string read GetCatlaog write FCataProperty stored true;
end;
procedure Register;
implementation
var
CName:string;
procedure Register;
begin
RegisterComponents('HDC4', [TssTest]);
RegisterPropertyEditor(TypeInfo(string),TssTest,'Catalog',TCataProperty);
end;
{ TCataProperty }
function TCataProperty.GetAttributes: TPropertyAttributes;
begin
result := [paValueList];
end;
function TCataProperty.GetValue: string;
begin
result := CName;
end;
procedure TCataProperty.GetValues(proc: TGetStrProc);
var
i:integer; st:TStringList;
begin
//st := TStringList.Create;
//for i:=0 to 4 do
// st.Add(inttostr(i));
for i:=0 to 4 do
begin
proc (inttostr(i));
end;
end;
procedure TCataProperty.SetValue(const Value:String);
begin
CName := Value;
end;
{ TssTest }
function TssTest.GetCatlaog: string;
begin
result := CName;
FCataProperty:= CName;
end;
end.