Thanks for your reply Cosmin. I'm not using any 3rd party components that use the TListView so there should be no handles being destroyed.
I take it the TVirtualTreeView is a free 3rd party component. I'll have a look at it. Thanks, Ross. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Cosmin Prund Sent: Monday, 13 August 2007 1:44 To: Borland's Delphi Discussion List Subject: RE: Rare access violations reading listitem.subitems On 12 august 2007 11:12 Ross Levis wrote: Subject: RE: Rare access violations reading listitem.subitems > > What would cause the handle to be recreated? It seems odd to me that > it has > never affected accessing the caption but only the SubItems which is a > TStrings. There's DestroyWindowHandle and DestroyWnd. Take a look at TWinControl.DestroyWnd in the Help - it might point somewhere. If you're using 3rd party components do a search for the calls in the source files. Might help. Also it might be a completely different problem. > I was contemplating using the TListItem.Data property to store pointers > to > records or data objects containing the associated data. Presumably the > Data > property is strictly a Delphi property and does not rely on a Windows > handle. Is that correct? Looking at the code for TListItem.Data it seems to be Delphi-only. So does the code for TListItem.SubItem so that might not be the problem. If you can reproduce the bug take a look at TListView.OnCreateItemClass. Put breakpoints in the constructor/destructor (or log those actions) - maybe you're using a "dead" instance of an TListItem. Another idea: just because your code AV's at the SECOND sub-item it's no guarantee that the first sub-item was an valid instance. Free-ing objects doesn't zero-out memory (it would be a nice debugging option those) and at times you may get lucky - ie: you may access an destroyed object before it gets it's memory reused. I'm saying this because you might assume the TListItem is good since you were able to access Caption and the first few SubItems but that's not always the case. Yet another idea: Since you're using TListView I'm assuming you're using the TListView in Detailed mode. Have you considered replacing it with an TVirtualTreeView? It looks virtually the same for the end user but you get the chance to store data in your own objects, so there's no chance of anything getting freed or re-created behind your back! -- Cosmin Prund _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

