搞不明白了 Tlist 和 结构的问题
wheat 2001-09-18 10:04:23 static TList *MyList = new TList; //全局静态
typedef struct AList
{
int I;
char C;
} TAList;
typedef TAList* PAList;
前提:
按两次以上的按钮,取不出数据
void __fastcall TForm1::Button1Click(TObject *Sender)
{
PAList AStruct;
AStruct = new TAList;
if (MyList->Count !=0 ) //判断MyList是不是有数值
{
for (int i = 0; i < MyList->Count; i++)
{
AStruct = (PAList) MyList->Items[i];
char temp= AStruct->IP; /////重要点,要在这里取出第一ADD到MyList的数组
}
}else{//第一次添加到Mylist中
AStruct->I = 100;
AStruct->C = 'Z';
MyList->Add(AStruct);
AStruct = (PAList) MyList->Items[i];
char temp= AStruct->IP; //测试、在这里就可以取出来
}
// 删除 AStruct 后,问题在第二次出现,即数值取不出来
delete AStruct;
}
//----------------------------------------------------------------------
// FromClose 时
{
delete MyList;
}
问题是按第二次按钮时,数据按结构的方式,在Tlist中 提取不出来
非常着急
写了这么多,大侠请帮忙或给各思路也行,非常非常感谢