D
demogorgon
Unregistered / Unconfirmed
GUEST, unregistred user!
//定义的属性
type
TPairListProperty = class(TPropertyEditor)
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
////////////////在属性编辑器中编辑属性
////////////////TPairList和TValuePair都是自定义类型
///////////////下面的代码在设计时会出错,能弹出对话框
//bow~
procedure TPairListProperty.Edit;
var
Dlg: TPairListSettingDlg; //一个对话框
pl,pl2: TPairList;
vp: TValuePair;
begin
Dlg := TPairListSettingDlg.Create(Application);
try
with Dlg do
begin
Caption := 'Create PairList';
ShowModal;
//创建自定义类型的实例
pl := TPairList.Create;
vp := TValuePair.Create('sUserName', 'UserName');
pl.Add(vp);
//向属性编辑器设置属性
SetOrdValue(LongInt(@pl));
//读出属性
pl2 := TPairList(GetOrdValue);
//显示读出的属性
if pl2 = nil then
Showmessage('nil')
else
Showmessage(pl2.ElementAt(0).GetValue);
pl.Free;
pl2.Free;
end;
finally
Dlg.Free;
end
end;
type
TPairListProperty = class(TPropertyEditor)
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
////////////////在属性编辑器中编辑属性
////////////////TPairList和TValuePair都是自定义类型
///////////////下面的代码在设计时会出错,能弹出对话框
//bow~
procedure TPairListProperty.Edit;
var
Dlg: TPairListSettingDlg; //一个对话框
pl,pl2: TPairList;
vp: TValuePair;
begin
Dlg := TPairListSettingDlg.Create(Application);
try
with Dlg do
begin
Caption := 'Create PairList';
ShowModal;
//创建自定义类型的实例
pl := TPairList.Create;
vp := TValuePair.Create('sUserName', 'UserName');
pl.Add(vp);
//向属性编辑器设置属性
SetOrdValue(LongInt(@pl));
//读出属性
pl2 := TPairList(GetOrdValue);
//显示读出的属性
if pl2 = nil then
Showmessage('nil')
else
Showmessage(pl2.ElementAt(0).GetValue);
pl.Free;
pl2.Free;
end;
finally
Dlg.Free;
end
end;