我有好几种类型的Record,不同的Pointer,放在TreeView的Item的Data中,我遍历的时候得到的是Pointer,如何判断是属于不同的Record
解决方案 »
- 创建窗体时TDirDialog类没有找到
- 通过读取PE找到了EXE文件的图标偏移,但是应该怎么样读出来啊?
- 今天看了看windows核心编程这本书, 内存管理有几个问题模糊,问问各位老大们?
- "Timeout exceeded"提示框
- ★★★关于游戏修改,有些难度,请高手帮帮★★★
- 小数能用 十进制表示吗????????????????????????
- 计算机没有网卡,能使用sql做本地数据库吗
- ESMTP 的问题,对邮件编程感兴趣的朋友进来研究一下?
- 最近一个项目,有复杂的财务报表,我不想用Excel了,不知其它的哪个报表组件好?
- 急!如何实现表中的列的计算
- 枚举类型错误所在?
- 请高手帮我看下 这个 很简单的sql 语句的问题,非常非常感谢
DATA1 = 1;
DATA2 = 2;
DATA3 = 3;type
TData = record
DataType: Integer;
Data: Pointer;
end; TData1 = record end; TData2 = record end; TData3 = record end;
function NewData1(AData1: TData1): TData;
begin
New(Result);
Result.DataType := Data1;
Result.Data := AllocMem(SizeOf(TData1));
Result.Data^ := AData1;
end;....
type
RecType = (type1, type2, type3);
PRecType = ^RecType; Rec1 = record
typeid: RecType;
data1: ...;
end;
PRec1 = ^Rec1; Rec2 = record
typeid: RecType;
data2: ...;
end;
PRec2 = ^Rec2; Rec3 = record
typeid: RecType;
data3: ...;
end;
PRec3 = ^Rec3;
使用时:
p: Pointer; p = treenode.Data;
case PRecType(p)^ of
type1: 处理第一种类型
type2: 处理第二种类型
type3: 处理第三种类型
end;
Delphi中有无可以实现 add(tag:integer;object:TObject)的List,Hash过的,可以快速实现定位
把信息封装不同的类,
Tmain = class;
public
ftype: integer; //用来区分不同的类型
constructor Create(vtype: integer); virtual;
end;Tchild = Class(Tmain)
public
//data: ...你的相关数据
constructor Create(vtype: integer); override;
end;
end;////////
var
list: TObjectList;
a: Tmain;
begin
a := Tchild.create(1);
list.add(a);
//添加多个....
for i := 0 to list.cout-1 do
begin
case Tmain(list.items[i]).ftype do
1:;
2:;
end;
end;