i have a listview that i fill with info from a text file. the problem arises when the text file is a large one such as 5megs. my application will use 100% if i use a large text file. can someone give me some suggestions on how to fix this.

just test it on a large text file that has list of lists of items in it. here is my code:
Posted on 2002-03-21 19:09:09 by smurf
Hey smurf,

test.txt

Never seen a listview that act like that before.
I wonder do the two difference type of StrLen have anything to do with it. It's lighting on a small file. I'm going not to try the 5 and 6mg.

I will see if i can come up with anything tonight.
Posted on 2002-03-21 20:47:57 by cmax
Sounds like you need something like the "DoEvents" command in VB, which temporarily gives control back to the OS so it can do its stuff, it is especially useful in tight loops. But i am not sure how to implement this in asm :) Maybe use a separate thread to fill the listview?
Posted on 2002-03-21 22:09:36 by sluggy
smurf,

Modified some and tested 9 mega test file. no problem!!

I found twos in your code.

I ask u...

1.
szLinebuf db 256 dup (?) ;;:confused:

I don't know your "test.txt", but is there any lines
more than 256 bytes? Verify your "test.txt" if it has more than
256 bytes a line. if not might below, i guess.

2.

mov eax,offset ThreadProc
invoke CreateThread, 0, 0, eax, 0, 0, addr ThreadID
;;;;;;;
invoke CloseHandle,eax ;;:confused:
;;;;;;;

i doubt this line especially.
this closes thread's handle immeately.
as i understande, CreateThread just start another process
and returns, so this code will close Thread handle immeately.

==============================================

I changed this like below, this close thread's handle after
all works end.


mov eax,offset ThreadProc
invoke CreateThread, 0, 0, eax, 0, 0, addr ThreadID
;;;;;;;;;;;;;;
mov hThread, eax
;;;;;;; invoke CloseHandle,eax
Posted on 2002-03-21 22:30:03 by muzidowa
cmax: thanks anyways looks like muzidowa figured it out already.

sluggy: thats what i actually did was created a new thread to fill the listview.

muzidowa: thank you very much for helping me out with this; it works great now.:alright: and thanks for the progress bar, ive never used one yet and was planning on using one here on my next project.
Posted on 2002-03-21 22:30:18 by smurf
9:15 PM

5.09 MB File

ListView is slow anyway. Try to open up xp system files that will give you an idea there. But this is kind of slow because it took 6 minute to go from top to bottom of 1.3 meg files. It still should not have taken this long.

Now I am looking at it right now and going to see how long it take to finish.

I copy it 5 times so i can see where i am....I guest i go and get a cup of coffee...

I don't know what you plan to use it for but it would be sharp if you add some control to do stuff like scanning. Maybe with a slow down and speed up thing. I like seeing these codes running by like this. It's even helping me to remember where stuff is.

This kool... I'm using win95B, P200, 96 MB Ram.. No effect on system performance...

It's like getting an snapshot of it all...Going though 4 copy now seem like it slicely slowed down or it could be me.

It me...You learn how to code quickly by watching it like you do TV.

It REALLY FINISHED AT 10:10 PM

50 MIN for a 5.09 MB File Take away 7 minute for not being the top most window for no more than 7 minutes. No Window energy lossed...

I start losing confident because it keep running BUT IT finished it job to the bottom LINE. Now someone who knows may be able to figure this out.

Pop a couple of buttons on it and have soom FUN...

See Ya
Posted on 2002-03-21 22:35:07 by cmax
cmax: ya i find the best way to learn is to just fiddle around with some code and to change it around to see what i can do with it. i too notice that it takes a while to load the file into the listview so there's gotta be a faster way. well i thank you for the effort your putting in.

muzidowa: i was messing around with the source you posted and i dont understand why it is that if i remove the progress bar the code doesnt work right. it assembles fine and everything but it starts using 100percent of my cpu again. why is that?

EDIT: after further testing of your code muzidowa, i notice that instead of using 100% or my cpu its using around 98 to 99% so i thought it was working well but its actually bringing down my system alot.
Posted on 2002-03-21 22:53:46 by smurf
smurf,

I can't understnad u..

As "CloseHandle, hThread"
I don't sure, where i positioned, or when.

I just think, it might be after ThreadProc returns.
...
Posted on 2002-03-21 23:48:36 by muzidowa
cmax: it looks as though i will need to use LVS_OWNERDATA. if you look into here http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_virtual_list_controls.asp you will find that this appears to be the solution. i dont quite understand what i need to do so hopefully you maybe able to help me out.
Posted on 2002-03-22 10:34:09 by smurf
Hey smurf,

I'm not that sharp. I can't read c. I looked at window.inc and it got more cont for LV than anything else.

I'm nothing more than a Box maker and basic string guy.

LV is preety heavy stuff once you get into it. And the only thing i ever worked with was EWane ListView. The guy website that got MasmEdit and WordEdit. He's probley the only guy who know the secretes to using LV in asm.

But I promise you i will be playing with-it for a while an the minite i stuble on something i let you know that very second.

But i am confussed about what you need...Speed or less CPU work to do it because you said something about 100%. :confused:
Posted on 2002-03-22 19:42:11 by cmax
smurf

I just thought about something. Your program is reading the file from the Hard Drive with an single thread....Thats why it's slow...

Read the File into Merory than (or as it) feed it to the ListView....

Mabe a 6MB Buffer if not use Globle Allocatate. Getting it in Merory must be just as fast as poping open a large doc file anyway i bet. Someone may know more about this.

Than ListView will run like a rocket than... Have not tried it yet but when i think about what MSDN saID about cache, that sound like in memory but maybe in a difference way...

Is this what cache mean....In Buffers or something...I reallly don't know just yet...Never paid it any attention..
Posted on 2002-03-23 06:47:26 by cmax
If I remember correctly, the slow part is having windows refresh the listview after each insert item. There was a way to add all
the items to the listview and then display them.

"If you are adding a large number of items to a list-view control, you can speed up the process by disabling redrawing before adding the items, then enable redrawing after the items are added. Use the WM_SETREDRAW message to enable and disable redrawing.
"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/CommCtls/ListView/ListView_Overview.asp?frame=true
Posted on 2002-03-24 12:22:00 by grv575
Try this on a 33k test.txt file. It's about 3x as fast but it's still real slow for large files.
Posted on 2002-03-24 13:13:03 by grv575
Hello,

I never tested the code but I think I know you guys mean. I've been working on an ide for awhile for another language, and noticed one thing, if a control like a treeview, or a listview have like 60000+ items, my computer slows wayyyy downnnn, I guess because of the way windows redraws and displays the loaded information (maybe because each item is basically an object with a few attributes and properties).

I have heard people placing the large amounts of data into memory or keeping the data file open for reading, then adding only a few items to the control, creating a "virtual listview" or virtual treeview which is much faster. Maybe implementing an ownerdrawen window would make it faster too. I've never tried something like this but the idea sounds like it would work quite well, and if you think about it, Microsot has done this with MS excel, the spread sheet loads new rows and columns dynamically not all at once giving the illusion that the user has an infinit amount of columns and rows to use.


Oops must have missed grv575 message on screen updating..

Hope I could help further,
James Emmrich
Posted on 2002-03-24 13:56:37 by JamesE