View Full Version : Here's a working virtual listview script
I'm sure somebody can use this someday....
You can 'load' millions of items within a second into the listview. The listview shows in fact only the records that should be visible. Instead of an array you can also use a database (FILE_GETR command for example). The 4th listview column in this example is a hidden column with the record numbers.
Key handling (up/down/home/end/pgup/pgdn) is done by the script
Horizontal and vertical scrollbars are virtual
Although I am pretty proud of it, I couldn't make this without the help of our master Eros, who solved some problems for me.
Petr Schreiber
02-09-2009, 18:00
:eusaclap:
Martin, this is very elegant solution,
thanks a lot for sharing!
ErosOlmi
02-09-2009, 18:18
Thank you very much martin.
I think it can be a great teaching example of anyone in need of a method to manage a lot of data.
Ciao
Eros
PS: I attached the script as file + added an image. Better for those willing to test it or get source.
To run the script, you need to have thinBasic at least version 1.7.9.0 beta or above
Hi Eros,
First of all, thanks for your hard work on the new ThinAir version. Unfortunately a lot of things aren't working yet, but I am very happy that the Undo problem has been solved!! :eusaclap:
Now my problem for today :lol:
I discovered a problem with the script I posted in this topic.
I have add small code to callback function cbSlave():
CASE %LVN_COLUMNCLICK 'sort the listview
do while not Terminate
'some commands here
doevents
loop
In the dialog callback function WindowMainProc() I set the global viariable Terminate to %TRUE when the dialog is closed
CASE %WM_CLOSE
terminate=%true
STOP
You can find complete code in attachment....
If execute this script and then close the dialog by clicking the red closing-button (X) at the right top, the program crash. Is there a way to solve this? I tried the same code in another listview script and then everything works fine, I am pretty sure that this has something to do with the cbSlave callback function (i know....you already warned me that using this could be tricky :roll:)
Thanks in advance for your reply!
Martin
Oh, I forgot to tell that you must first click on a (grey) listview column and then close the dialog! Only then the program will crash
problem "solved" by removing doevents instruction
lydia_sp
07-09-2009, 16:07
martin, how to use your script ?
some minutes before I wanted to write you, that your script causes at my pc more than one gpf`s. you are faster, good guy! I will test your script again :) thanks!
bye, lydia
martin, how to use your script ?
some minutes before I wanted to write you, that your script causes at my pc more than one gpf`s. you are faster, good guy! I will test your script again :) thanks!
bye, lydia
Lydia, as fas as I know my script should work fine, but please download the one at the top of this topic http://community.thinbasic.com/index.php?action=dlattach;topic=2895.0;attach=5692
Please let me know if there's something wrong, i hate errors :grrrr:
lydia_sp
07-09-2009, 16:21
works fine ! have downloaded another script of this morning :)
saludos, lydia
lydia_sp
08-09-2009, 14:01
hello martin.
my instincts are correct ;)
your last script has the problem I have noticed yesterday morning. your first script (first post) is ok.
the last script: may be a problem in line 32 (please use debug modus!) with F8 you will come into a loop and cannot check whole script.
if I push grey column then any line below, close the window the gpf will come.
lydia
Hi Lydia,
Please ignore the last script, it was just an example for Eros to show him a problem. I don't know why ThinDebug doesn't come out that FOR-NEXT loop, maybe Eros can tell....it's strange indeed because this problem does not seems to happen when you run the script in normal mode (without ThinDebug).
Have a nice day,
Martin
Jordi Vallès
09-09-2009, 18:43
Do you know this note?
" Background color to set or the CLR_NONE value for no background color. List-view controls with background colors redraw themselves significantly faster than those without background colors."
on http://msdn.microsoft.com/en-us/library/bb761153%28VS.85%29.aspx
I verified this and is true.
Also in http://www.powerbasic.com/support/forums/Forum7/HTML/002913.html
Petr Schreiber
09-09-2009, 19:12
Hi Jordi,
thanks for the tip, I didn't know this trick!