Board index » cppbuilder » TListView->Items->Clear() : Invalid Pointer operation & access violation

TListView->Items->Clear() : Invalid Pointer operation & access violation

In order to clear a list, it must contains items on it. Try better to clear
each item using ListItem instead.
Quote
"Jeong ho,Shin" wrote:
> Hi...

> I have tried to execute like follow code:

> ListView1->Items->Clear();

> It looks like that this code was executed normally.

> But, Often I met the messages like follows

> 1. Invalid Pointer Operation
>    : If I click OK button, and then cotinued.

> 2. Access violation at address 400004954 in module 'vcl40.bpl'. Read of
> address BC400345
>    : If I click OK button, and then cotinued.

> 3. Access violation at address 77FC9E84 in module 'ntdll.dll'. Write of
> address 00000004
>    : If I click OK button, and then terminated.

> I Just called only "ListView1->Items->Clear()".

> So, I have checked  "ListView1->Items->Count" after calling
> "ListView1->Items->Clear()".

> It must be "ListView1->Items->Count" is 0 after  calling
> "ListView1->Items->Clear()".

> but sometimes  "ListView1->Items->Count" is not 0 when the message 1,2 was
> occured.

> How can I solve this problem???

> Is this problem because TListView is wrong ???

> or any part of my code is wrong ???

> If any part of my code is wrong, how is wrong ??? what should i know???

 

Re:TListView->Items->Clear() : Invalid Pointer operation & access violation


: "Jeong ho,Shin" <deck...@shinbiro.com> wrote:

Quote
>If any part of my code is wrong, how is wrong ???

Without seeing the smallest piece of code that reproduces the problem for
you, it is impossible to say what is wrong.

Calling

  ListView1->Items->Clear();

is a very straight-forward, harmless thing to do.

--
General information:
  * Post to the right group - http://www.borland.com/newsgroups/
    * Do not cross- or multipost
      * Research at http://www.mers.com/searchsite.html

Stefan Hoffmeister - http://www.econos.de/
(TeamB - http://www.teamb.com/)

Re:TListView->Items->Clear() : Invalid Pointer operation & access violation


: "Johny K." <johnyk...@hotmail.com> wrote:

Quote
>In order to clear a list, it must contains items on it.

No.

--
General information:
  * Post to the right group - http://www.borland.com/newsgroups/
    * Do not cross- or multipost
      * Research at http://www.mers.com/searchsite.html

Stefan Hoffmeister - http://www.econos.de/
(TeamB - http://www.teamb.com/)

Re:TListView->Items->Clear() : Invalid Pointer operation & access violation


Quote
"Stefan Hoffmeister (TeamB)" wrote:

> : "Jeong ho,Shin" <deck...@shinbiro.com> wrote:

> >If any part of my code is wrong, how is wrong ???

> Without seeing the smallest piece of code that reproduces the problem for
> you, it is impossible to say what is wrong.

> Calling

>   ListView1->Items->Clear();

> is a very straight-forward, harmless thing to do.

Unless of course Jeong ho,Shin has declared ListView1 without allocating
space for it?

liz

Re:TListView->Items->Clear() : Invalid Pointer operation & access violation


: Liz Albin <Elizabeth.Al...@Bowne.com> wrote:

Quote
>Unless of course Jeong ho,Shin has declared ListView1 without allocating
>space for it?

True. But typically "ListView1" indicates one of the components that live
on a form. I cannot believe that anyone would name a "manually" handled
listview that way.

--
General information:
  * Post to the right group - http://www.borland.com/newsgroups/
    * Do not cross- or multipost
      * Research at http://www.mers.com/searchsite.html

Stefan Hoffmeister - http://www.econos.de/
(TeamB - http://www.teamb.com/)

Re:TListView->Items->Clear() : Invalid Pointer operation & access violation


Quote
"Stefan Hoffmeister (TeamB)" wrote:

> : Liz Albin <Elizabeth.Al...@Bowne.com> wrote:

> >Unless of course Jeong ho,Shin has declared ListView1 without allocating
> >space for it?

> True. But typically "ListView1" indicates one of the components that live
> on a form. I cannot believe that anyone would name a "manually" handled
> listview that way.

That's why I was hesitant to say anything.

Re:TListView->Items->Clear() : Invalid Pointer operation & access violation


If you have have an OnDeletion event handler, you might take a look at that.
A bad ListItem->Data pointer could do it.

Re:TListView->Items->Clear() : Invalid Pointer operation & access violation


Hi...

I have tried to execute like follow code:

ListView1->Items->Clear();

It looks like that this code was executed normally.

But, Often I met the messages like follows

1. Invalid Pointer Operation
   : If I click OK button, and then cotinued.

2. Access violation at address 400004954 in module 'vcl40.bpl'. Read of
address BC400345
   : If I click OK button, and then cotinued.

3. Access violation at address 77FC9E84 in module 'ntdll.dll'. Write of
address 00000004
   : If I click OK button, and then terminated.

I Just called only "ListView1->Items->Clear()".

So, I have checked  "ListView1->Items->Count" after calling
"ListView1->Items->Clear()".

It must be "ListView1->Items->Count" is 0 after  calling
"ListView1->Items->Clear()".

but sometimes  "ListView1->Items->Count" is not 0 when the message 1,2 was
occured.

How can I solve this problem???

Is this problem because TListView is wrong ???

or any part of my code is wrong ???

If any part of my code is wrong, how is wrong ??? what should i know???

Other Threads