再补充一句,跟什么tid释放无关
就算不用addobtect,只用add,也是一样的
例:
unit CHOPCombobox;
interface
uses
SysUtils, Classes, Controls, StdCtrls,Forms,messages,CHManageDBConn,shareproc,
CustomDataClass,Dialogs;
type
TComboBoxTest = class(TComboBox)
private
{ Private declarations }
protected
{ Protected declarations }
public
procedure CreateWnd;override;
// constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{ Public declarations }
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('CHGroupware', [TComboBoxTest]);
end;
{ TComboBoxTest }
procedure TComboBoxTest.CreateWnd;
begin
inherited CreateWnd;
if not (csDesigning in ComponentState) then
begin
self.Tag:=111;
items.Add('bbbbbbbb');
items.Add('aaaaaaa');
items.Add('ccccc');
end;
end;
destructor TComboBoxTest.Destroy;
begin
if not (csDesigning in ComponentState) then
showmessage(items[0]);//这里会出错
// showmessage(inttostr((self.items.Objects[1] as tid).id));
inherited Destroy;
end;