我在node.data里面存储的数据,取出来的时候是空的,为什么?
有人能提供一个如何取得指针变量数值的方法么?
有人能提供一个如何取得指针变量数值的方法么?
解决方案 »
- [高分求解简单SQL问题]动态报表如何生成?我做的一个小系统的最后一个模块?请各位给点建议,顶者有分
- 谁有 delphi 大整数运算库程序啊(用字符串实现很大的字符加减乘除),发个给我好吗?急死俺了!!!
- vclskin里的SkinData1控件的skinfile属性,如果要写相对路径怎么写?多谢
- 郁闷!小区遭雷击,液晶显示器损坏
- 问一个如何安装组件的问题
- delphi中如何使用com
- delphi 指针搜索问题
- 急,请问大家哪里有控件dxdbtreeview的下载,谢谢!
- delphi里面怎么区别鼠标单击和双击
- 各位高手,我是初学者,能介绍一本关于pascal方面的书吗?
- 请ghyghost(著名关心CSDN结贴率爱国主义人士代表) ( ) 进来领分。
- 连接及查询问题
begin
...
showMessage(p^)
end ;
node.data是pointer类型的。
如果你的node.data里面存储的是一个类的数据(TFileData)
用下面的方法取数据
TFileData(Node.data).Property;propert为tfiledata的属性
rootNode: TTreeNode;
pModule: ^CModuleObject;
i: integer;
begin
self.query:=query;
self.tree:=tree;
tree.Items.Clear;
new(pModule);
pModule^:=CModuleObject.create(0,'***',MODULE_FOLDER);
rootNode:=tree.Items.AddObject(nil, pModule^.innerName, pModule);
getNode(rootNode, pModule^.innerCode);
rootNode.Expand(true);
for i:=0 to rootNode.Count-1 do
rootNode.Item[i].Collapse(true);
end;
PMyRec = ^TMyRec;
TMyRec = record
FName: string;
LName: string;
end;Assuming these types are used, the following code adds a node to TreeView1 as the last sibling of a specified node. A TMyRec record is associated with the added item. The FName and LName fields are obtained from edit boxes Edit1 and Edit2. The Index parameter is obtained from edit box Edit3. The item is added only if the Index is a valid value.procedure TForm1.Button1Click(Sender: TObject);var
MyRecPtr: PMyRec;
TreeViewIndex: LongInt;
begin
New(MyRecPtr);
MyRecPtr^.FName := Edit1.Text;
MyRecPtr^.LName := Edit2.Text;
TreeViewIndex := StrToInt(Edit3.Text);
with TreeView1 do
begin
if Items.Count = 0 then
Items.AddObject(nil, 'Item' + IntToStr(TreeViewIndex), MyRecPtr)
else if (TreeViewIndex < Items.Count) and (TreeViewIndex >= 0) then Items.AddObject(Items[TreeViewIndex], 'Item' + IntToStr(TreeViewIndex), MyRecPtr);
end;
end;After an item containing a TMyRec record has been added, the following code retrieves the FName and LName values associated with the item and displays the values in a label.procedure TForm1.Button2Click(Sender: TObject);begin
Label1.Caption := PMyRec(TreeView1.Selected.Data)^.FName + ' ' +
PMyRec(TreeView1.Selected.Data)^.LName;
end;