Technology Learning

导航

动态创建 listbox释放问题

procedure TForm5.FormCreate(Sender: TObject);
begin
//**********
  ListBox1:=TListBox.Create(self);
  ListBox1.Parent:=self;

  ListBox1.Left:=100;
  ListBox1.Top:=100;
  ListBox1.Width:=400;
  ListBox1.Height:=400;

  ListBox1.Style:=lbOwnerDrawVariable;
   ListBox1.ItemHeight:=100;
  ListBox1.AddItem('123',self);


end;

 

 

procedure TForm5.FormDestroy(Sender: TObject);
begin
//*************

//ListBox1.Style:=lbStandard;//
ListBox1.Free;
end;

 

出现Exception class EAccessViolation with message 'Access violation at address 7C93B1FA in module 'ntdll.dll'.问题??

 

解决方案:

在free之前,还原风格,ListBox1.Style:=lbStandard;

OK!!!

 

 

posted on 2010-03-25 10:28  浔阳渔夫  阅读(671)  评论(0编辑  收藏  举报