[lazarus] Order of destruction in TCustomListBox

Vincent Snijders vslist at zonnet.nl
Fri Dec 12 10:50:39 EST 2003


Hi,

The destructor of TCustomListBox is:
destructor TCustomListBox.Destroy;
begin
  FreeAndNil(FCanvas);
  inherited Destroy;
  FreeAndNil(FItems);
end;

As I am implementing the TCheckListBox items collection for win32, I
would like to access the listbox handle, while in the destructor of the
items collection. Unfortunately the window (+ items + item data stored
in it) are lost before the destructor for the items collection is
called. 

Therefore I want to ask, if it is possible to change to destructor to:
destructor TCustomListBox.Destroy;
begin
  FreeAndNil(FCanvas);
  FreeAndNil(FItems);
  inherited Destroy;
end;

If this is not possible, I will probably find another way to close the
checklistbox without memory leaks, but changing this is easier for me.

Regards,
Vincent.










More information about the Lazarus mailing list