在form的onshow事件中,其中执行一句:
TreeView1.Items.AddObject(newnode,'张三',ptr1);
其中,ptr是本过程中申明的指针类,它是记录MyRec类的指针,为什么定义后,以后在TreeView1中点items,就会自动转到ptr指针所指的地址?(非'张三'的地址)?
比如:
TYPE
ptr=^MyRec;
MyRec=record
a:integer;
b:integer;
end;
begin
var
ptr1:ptr;
begin
new(ptr);
TreeView1.Items.AddObject(newnode,'张三',ptr1);
end; 以后,在TreeView中点击'张三',就会指向ptr,就是这点不理解?
TreeView1.Items.AddObject(newnode,'张三',ptr1);
其中,ptr是本过程中申明的指针类,它是记录MyRec类的指针,为什么定义后,以后在TreeView1中点items,就会自动转到ptr指针所指的地址?(非'张三'的地址)?
比如:
TYPE
ptr=^MyRec;
MyRec=record
a:integer;
b:integer;
end;
begin
var
ptr1:ptr;
begin
new(ptr);
TreeView1.Items.AddObject(newnode,'张三',ptr1);
end; 以后,在TreeView中点击'张三',就会指向ptr,就是这点不理解?
解决方案 »
- 用indy发邮件,提示connection closed gracefully!
- delphi 更改可执行文件图标
- 重要问题,帮忙
- delphi安装的问题?
- [求助]:ConnectNamedPipe在Win98下面可以用嗎?
- 有谁知道,哪里有能看DELPHI程序写的软件用了哪些VCL控件的?
- 我在批量处理的情况下 adodataset1.DeleteRecords(arCurrent);为什么错误?
- 请高手指点???!!!
- 在网络编程方面有发言权的就来看看!
- 我这种人在外边有没有的混?
- 关于STRINGGRID的问题,如何知道已退出某个cell?急……
- 【100分,会者不难】TreeView的一个小问题...
DescriptionThe node is added as the last sibling of the node specified by the Node parameter. The S parameter specifies the Text property of the new node. The Ptr parameter specifies the Data property value of the new node. AddObject returns the node that has been added. Note: The memory referenced by Ptr is not freed when the tree nodes object is freed.
----> 注意: Ptr: Pointer
再问一句,除了TreeView之外,还有什么组件可以这么用?
回答了马上给分!!
TList的子类都基本有的
TListBox,TListView之类的http://lysoft.7u7.net
gencheng() 只要是指针,就都可以这么用