Board index » delphi » Access Violation at ListView click

Access Violation at ListView click

I am getting an Access Violation when clicking a ListView component.
The de{*word*81} is stopping at the line:

abc:=Listview.selected.Caption;

where abc is a global string variable set in a different program. This
program is used
several times and will be created and destroyed every time when it is
called.

How can I approach this access violation problem. Are there helpful
compilersettings avialable?

Mathew

 

Re:Access Violation at ListView click


I am getting an Access Violation when clicking a ListView component.
The de{*word*81} is stopping at the line:

abc:=Listview.selected.Caption;

where abc is a global string variable set in a different program. This
program is used
several times and will be created and destroyed every time when it is
called.

How can I approach this access violation problem. Are there helpful
compilersettings avialable?

Mathew

Re:Access Violation at ListView click


You might want to test whether the ListView.Selected is actually pointing to
anything prior to accessing its properties.

For example:

if ListView.Selected <> nil then
  abc := ListView.Selected.Caption;

Best Regards,
Eric W. Carman

Quote
"Mathew" <xyz> wrote in message news:3cc985c7$1_1@dnews...
> I am getting an Access Violation when clicking a ListView component.
> The de{*word*81} is stopping at the line:

> abc:=Listview.selected.Caption;

> where abc is a global string variable set in a different program. This
> program is used
> several times and will be created and destroyed every time when it is
> called.

> How can I approach this access violation problem. Are there helpful
> compilersettings avialable?

> Mathew

Re:Access Violation at ListView click


Quote
In article <3cc9856b_1@dnews>, Mathew wrote:
> I am getting an Access Violation when clicking a ListView component.
> The de{*word*81} is stopping at the line:

> abc:=Listview.selected.Caption;

> where abc is a global string variable set in a different program.

You are probably over-optimistic and assume blindly that there will be a
selected item in the listview. Optimists have a short half-life in
Windows programming <G>.

 If Assigned( listview.selected ) Then
   abc := Listview.selected.Caption
 Else
   abc := '';

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Other Threads