| View previous topic :: View next topic |
| Author |
Message |
qyte Guest
|
Posted: Tue Mar 29, 2005 2:53 pm Post subject: TListView crashes windows. |
|
|
I have created a listview and get the correct images for it's items
using SHGetFileInfo. the problem that i have is that when i add more
than 3000 items the program crashes. in fact all windows crash. the
menus from then on are shown black. I believe that maybe the problem is
that i add the items in a while loop and maybe i should not put them
that very fast. can anyone help me?
The program has NO PROBLEM at all if i add less than 3000 items.
ps.
3000 is not an exact number. i have just tested it with desplaying 3000
items and 4000 items. in the first case it worked fine but the second
the above problem appears. The program doesn't stop running, the thing
is that after the addition the forms borders dissappear, some buttons as
well and the menus go black.
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Tue Mar 29, 2005 3:13 pm Post subject: Re: TListView crashes windows. |
|
|
qyte wrote:
| Quote: | I have created a listview and get the correct images for it's items
using SHGetFileInfo. the problem that i have is that when i add more
than 3000 items the program crashes. in fact all windows crash.
|
I don't think you mean 'crash'. In computing the word 'crash' typically
denotes sudden and total failure in much the same way as it does in the
wider world "there was a car crash", "my computer crashed".
What you are describing is a graphical rendering issue and from your
description is probably due to Windows running out of resources. What
version of Windows are you running? I would take a guess at Win9x. I'd
expect the full 32-bit versions of Windows to be okay with 'only' 3000
items.
However what you really should be doing is making the list view
virtual. What this means is that the list view only holds a simple
identifier for each object rather than all the data. The data is only
generated/obtained as/when it is needed. That way graphical information
usually only has to be held while the item is actually being displayed
and that significantly reduces the load on the operating system. It has
a major benefit on performance as well.
For more information on virtual list views bring a TListView up in the
ObjectInspector, select the OwnerData property and press [F1]. There
are some caveats that affect virtual list views but most people don't
encounter them.
FWIW the first time you try to implement a virtual listview it can seem
a bit daunting and you can get confused but stick with it. It isn't
really all that difficult :)
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
qyte Guest
|
Posted: Tue Mar 29, 2005 4:11 pm Post subject: Re: TListView crashes windows. |
|
|
Andrue Cope [TeamB] wrote:
| Quote: | What version of Windows are you running?
|
winxp sp2.
| Quote: |
However what you really should be doing is making the list view
virtual. What this means is that the list view only holds a simple
identifier for each object rather than all the data. The data is only
generated/obtained as/when it is needed. That way graphical information
usually only has to be held while the item is actually being displayed
and that significantly reduces the load on the operating system. It has
a major benefit on performance as well.
For more information on virtual list views bring a TListView up in the
ObjectInspector, select the OwnerData property and press [F1]. There
are some caveats that affect virtual list views but most people don't
encounter them.
FWIW the first time you try to implement a virtual listview it can seem
a bit daunting and you can get confused but stick with it. It isn't
really all that difficult :)
|
can you tell me how i can use the OnData and other events that you
describe? the thing is that i don't have the items stores anywhere.
what happens when i add an item to the list if it is virtual?
can i use it's values later on in those events?
|
|
| Back to top |
|
 |
Andrue Cope [TeamB] Guest
|
Posted: Tue Mar 29, 2005 4:24 pm Post subject: Re: TListView crashes windows. |
|
|
qyte wrote:
| Quote: | can you tell me how i can use the OnData and other events that you
describe?
|
The crux of the matter is that in the OnData handler you get passed a
TListItem. The only part of that TListItem that is populated for you is
the ItemIndex. You have to use that value to populate the rest of the
TListItem.
How you go about that is entirely up to you. Personally I used a
std::vector to hold information from which the properties can be
constructed but you could also use the value as a unique identifier
into a database.
Populating the TListView initially is just a matter of setting the
Count property. At present you'll have a big loop that instantiates a
TListItem, populates it then stuffs it into the TListView.
With a virtual list view you get rid of the big loop and just have a
function that populates the passed in TListItem based upon its
ItemIndex. The VCL will call that function each and everytime something
accesses a TListItem.
--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
|
|
| Back to top |
|
 |
Josh Jameson Guest
|
Posted: Tue Mar 29, 2005 4:50 pm Post subject: Re: TListView crashes windows. |
|
|
| Quote: | can you tell me how i can use the OnData and other events that you
describe? the thing is that i don't have the items stores anywhere.
|
Don't forget OnDataHint() too, it seems no one ever posted any
snippets
on using that one.
|
|
| Back to top |
|
 |
Damon Chandler (TeamB) Guest
|
Posted: Tue Mar 29, 2005 4:56 pm Post subject: Re: TListView crashes windows. |
|
|
Hi,
If you're interested in creating an Explorer-type list view control,
you can actually use the one Windows itself uses. Have a look at the
following article...
http://bcbjournal.org/free_issue/June03-01.htm
I'd be happy to send you the source code if you find the technique useful.
Good luck,
--
Damon (TeamB)
C++Builder Developer's Journal
http://bcbjournal.com
BCB Commonly Asked Questions
http://bcbjournal.com/bcbcaq
qyte wrote:
| Quote: | I have created a listview and get the correct images for it's items
using SHGetFileInfo.
|
|
|
| Back to top |
|
 |
qyte Guest
|
Posted: Tue Mar 29, 2005 5:21 pm Post subject: Re: TListView crashes windows. |
|
|
Damon Chandler (TeamB) wrote:
| Quote: | Hi,
If you're interested in creating an Explorer-type list view control,
you can actually use the one Windows itself uses. Have a look at the
following article...
|
that is a very good guide.
In fact what i want is to develop a finder program.
the actual problem occurrs when i search for (*).
and some other times depending on the amount of items.
I don't store the items values anywhere and so
i think it is difficult to display them using a virtual list.
i believe that something like that would be great but i have never
used it before.
I was wondering how can one add items to a virtual list?
if i use the
ListView->Items->Add();
method what exactly happens?
and when are the OnData* events called?
|
|
| Back to top |
|
 |
Damon Chandler (TeamB) Guest
|
Posted: Tue Mar 29, 2005 5:42 pm Post subject: Re: TListView crashes windows. |
|
|
The OnData event will be invoked whenever the list view needs to display
a certain item; see...
http://bcbjournal.org/articles/vol4/0001/Fast_updates_with_virtual_list_views.htm
But, a virtual list view requires that you store the data yourself and
provide it to the list view from within OnData. So, if you want to use
a virtual list view, you'll need to store your items in a separate
container (e.g., TObjectList). BTW, you don't need to use the
TListItems::Add() method; just set the Count property.
Cheers,
--
Damon (TeamB)
C++Builder Developer's Journal
http://bcbjournal.com
BCB Commonly Asked Questions
http://bcbjournal.com/bcbcaq
qyte wrote:
| Quote: | I don't store the items values anywhere and so
i think it is difficult to display them using a virtual list.
i believe that something like that would be great but i have never
used it before.
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Mar 29, 2005 8:38 pm Post subject: Re: TListView crashes windows. |
|
|
"qyte" <gyte (AT) vivodinet (DOT) gr> wrote
| Quote: | I have created a listview and get the correct images for it's items
using SHGetFileInfo. the problem that i have is that when i add
more than 3000 items the program crashes.
|
Please show your actual code.
Gambit
|
|
| Back to top |
|
 |
qyte Guest
|
Posted: Tue Mar 29, 2005 11:04 pm Post subject: Re: TListView crashes windows. |
|
|
Damon Chandler (TeamB) wrote:
| Quote: | But, a virtual list view requires that you store the data yourself and
provide it to the list view from within OnData. So, if you want to use
a virtual list view, you'll need to store your items in a separate
container (e.g., TObjectList). BTW, you don't need to use the
TListItems::Add() method; just set the Count property.
|
i followed the instrunctions in the link you showed and managed to
accomplish it. the problem that i now have is with subitems.
for the moment i do something like that.
OnData
Item->SubItems->Add(Something);
it works but i don't know if it is the right thing to do.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Mar 30, 2005 1:25 am Post subject: Re: TListView crashes windows. |
|
|
"qyte" <gyte (AT) vivodinet (DOT) gr> wrote
| Quote: | i followed the instrunctions in the link you showed and
managed to accomplish it. the problem that i now have
is with subitems.
|
What EXACTLY are you having a problem with? Please be more specific.
Gambit
|
|
| Back to top |
|
 |
Damon Chandler (TeamB) Guest
|
Posted: Wed Mar 30, 2005 2:19 am Post subject: Re: TListView crashes windows. |
|
|
Yes, using SubItems->Add() is the correct way to add subitems for a
virtual list view.
Cheers,
--
Damon (TeamB)
C++Builder Developer's Journal
http://bcbjournal.com
BCB Commonly Asked Questions
http://bcbjournal.com/bcbcaq
qyte wrote:
| Quote: | OnData
Item->SubItems->Add(Something);
it works but i don't know if it is the right thing to do.
|
|
|
| Back to top |
|
 |
qyte Guest
|
Posted: Wed Mar 30, 2005 11:23 am Post subject: Re: TListView crashes windows. |
|
|
Remy Lebeau (TeamB) wrote:
| Quote: | What EXACTLY are you having a problem with? Please be more specific.
|
I have no problem with the subitems now.
i know that the Subitems::Add() does the job.
what i would like to know is:
first.
will the Subitems be destroyed when i set
the ListView->items->count=0;
or will i have to delete them mannually?
besides that the problem that i faced from the beginning
is that when i increase the width of a column (not inside the program,
but as user) from a size after the program freezes and occupies 100%
processor without stopping. (the width that causes the problem is not
always the same, i believe that the list tries to do something with the
items not visible at that moment).
The column autosize is false. if i set it to true the program stops
having the above problem but it looks pretty bad when i resize the form.
for emample the forms dragged border dissappears until the drag is complete.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Mar 30, 2005 7:21 pm Post subject: Re: TListView crashes windows. |
|
|
"qyte" <gyte (AT) vivodinet (DOT) gr> wrote
| Quote: | will the Subitems be destroyed when i set
the ListView->items->count=0;
|
Yes.
| Quote: | or will i have to delete them mannually?
|
No.
Gambit
|
|
| Back to top |
|
 |
|