H
HongYuan
Unregistered / Unconfirmed
GUEST, unregistred user!
1。TObject = class中class代表什么?
2。TPressBookInfo=class
FBookType:integer;
FTypeName:string;
FPressID:integer;
end;这是我自已定义的。
sql:='select * from Sys_BookType ';
try
TempQuery := TADOQuery.Create(nil);
TempQuery.LockType := ltReadOnly;
OpenDataSet(TempQuery, sql);
while not TempQuery.Eof do
begin
PressInfo:=TPressBookInfo.Create;
PressInfo.FBookType:=TempQuery.FieldByName('BookTypeID').AsInteger;
PressInfo.FTypeName:=TempQuery.FieldByName('TypeName').AsString;
PressInfo.FBookName:='';
PressInfo.FBookID:=0;
PressInfo.FPressID:=0;
TreeNode:=bsSkinTreeView1.Items.AddChildObject(ParentNode,PressInfo.FTypeName,PressInfo);
TreeNode.ImageIndex:=3;
TreeNode.SelectedIndex:=3;
bsSkinTreeView1.Items.AddChild(TreeNode,'无');
TempQuery.Next;
end;
TempQuery.Close;
ParentNode.Expand(False);
finally
PressInfo:=nil;
FreeAndNil(TempQuery);
end;
多次 PressInfo:=TPressBookInfo.Create;不出错,不同于类?为何?
2。TPressBookInfo=class
FBookType:integer;
FTypeName:string;
FPressID:integer;
end;这是我自已定义的。
sql:='select * from Sys_BookType ';
try
TempQuery := TADOQuery.Create(nil);
TempQuery.LockType := ltReadOnly;
OpenDataSet(TempQuery, sql);
while not TempQuery.Eof do
begin
PressInfo:=TPressBookInfo.Create;
PressInfo.FBookType:=TempQuery.FieldByName('BookTypeID').AsInteger;
PressInfo.FTypeName:=TempQuery.FieldByName('TypeName').AsString;
PressInfo.FBookName:='';
PressInfo.FBookID:=0;
PressInfo.FPressID:=0;
TreeNode:=bsSkinTreeView1.Items.AddChildObject(ParentNode,PressInfo.FTypeName,PressInfo);
TreeNode.ImageIndex:=3;
TreeNode.SelectedIndex:=3;
bsSkinTreeView1.Items.AddChild(TreeNode,'无');
TempQuery.Next;
end;
TempQuery.Close;
ParentNode.Expand(False);
finally
PressInfo:=nil;
FreeAndNil(TempQuery);
end;
多次 PressInfo:=TPressBookInfo.Create;不出错,不同于类?为何?