代码如下:
unit ddgWorthless;interfaceuses
SysUtils, Classes, Controls;type
TddgWorthless = class(TCustomControl)
private
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('DDG', [TddgWorthless]);
end;
end.问:比如 在组件TddgWorthless中,我在何出声明一个对象(someobject),请在代码处表出,另外,我要使用到 集合等东东 ,同样我在何处声明?
对象定义如下:
type
TSomeObject = class(TPersistent)
private
FProp1 : Integer;
FProp2 : String;
public
procedure Assign(Source : TPersistent)
published
property prop1 : Integer read FProp1 write FProp1;
property prop2 : string read FProp2 write FProp2;
end;集合定义如下:
TSetPropOption = (poNoe,poTwo,PoThree,poFour,PoFive);
TSetProOptions = set of TSetPropOption;关键是我在何处把这些东西放在 我自定义一个组件的什么地方?
请高手指点/ 谢谢。
unit ddgWorthless;interfaceuses
SysUtils, Classes, Controls;type
TddgWorthless = class(TCustomControl)
private
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('DDG', [TddgWorthless]);
end;
end.问:比如 在组件TddgWorthless中,我在何出声明一个对象(someobject),请在代码处表出,另外,我要使用到 集合等东东 ,同样我在何处声明?
对象定义如下:
type
TSomeObject = class(TPersistent)
private
FProp1 : Integer;
FProp2 : String;
public
procedure Assign(Source : TPersistent)
published
property prop1 : Integer read FProp1 write FProp1;
property prop2 : string read FProp2 write FProp2;
end;集合定义如下:
TSetPropOption = (poNoe,poTwo,PoThree,poFour,PoFive);
TSetProOptions = set of TSetPropOption;关键是我在何处把这些东西放在 我自定义一个组件的什么地方?
请高手指点/ 谢谢。
procedure Assign(Source : TPersistent)
begin
......
end;
这些代码 写在哪里?
uses
SysUtils, Classes, Controls;后定义。
具体实现写在procedure Register;
begin
RegisterComponents('DDG', [TddgWorthless]);
end;后
这样就可以使用集合了。你也可以直接在类中定义:someobj:TSomeObject;啊~
前提是someobj类在他之前。