GUI ScreenIO for Windows

 ScreenIO.com


Listview Demonstration Program

Install this program on my system, including the source code.

This is a program we wrote to help us debug the listview control.  It allows you to play with a number of things that you can change at runtime, and to see how the listview control interacts with your program. 

The listboxes on the right side of the panel display the events the panel passes back to your program and the associated keys and/or percentage values.  In the example shown, we told our program to pretend there were 100 items in its list, and that the listview buffer was only 10 records; that is, we only pass the listview 10 records at a time.

Loading the Listview

You can see the first event was Set Size, which was the event returned when the Create the Listview button is pressed.

In response to this, the demonstration program loaded 10 items to its listview buffer and called GUI ScreenIO.

GUI ScreenIO copied the ten records to its cache and asked Windows to display the listview.  Because the listview can display 22 records, GUI ScreenIO asks you for more data:  It returned a GET-NEXT event, and a value of 10 in mylist-GET-FROM-KEY.  The demonstration simulates positioning its file at record 10 and loads ten records to the listview buffer, beginning with record 10.

It then calls GUI ScreenIO to pass it the records.  Because GUI ScreenIO still needs a few more records, it returns another GET-NEXT event with a GET-FROM-KEY of 19.  The simulator program responds by loading the listview buffer with ten records, beginning with record 19, and calling GUI ScreenIO again. 

Because GUI ScreenIO now has enough data to fill the listview window, it will not return to you with another request, it just waits for the user to do something.

What happens if the user clicks on the bottom of the scrollbar to cause the list to scroll?  Let's see:

Scrolling a Little

In the screen shot below, you see that GUI ScreenIO passed back two GET-NEXT events, with START-FROM-KEY values of 28 and 37.  Our program simply handled them as it did when it first loaded the listview; it positioned the file to the START-FROM-KEY and passed 10 records to GUI ScreenIO in the listview buffer. 

This will continue until the record with a percentage of 100 is passed, indicating it's the last record in the list.  From that point on, if all of the records are in the cache, GUI ScreenIO will display the records as the listview is scrolled without bothering you; all the data it needs is in its cache!

Let's try something else; let's simulate a file of, say, 10,000 records and then drag the scrollbar thumb to the 50 percent point.  What happens then?

Scrolling a Lot:  the START-AT-PERCENT event

Here it is, and notice something new:  There aren't any GET-NEXT events in the list!  Why not?

Because we made our simulated listview buffer bigger; we're now passing 100 records into the listview at a time.  Because this is more data than we need to display the first time, GUI ScreenIO doesn't need to ask for more data.  And it doesn't.

After the initial display, we dragged the scrollbar thumb about halfway down.  This time, because it would have taken too long to read sequentially down the file to that point, GUI ScreenIO returned a START-AT event, and returned the value 53.47465 in START-AT-PERCENT.

We responded by positioning our simulated file as close as possible to that point, and then passing GUI ScreenIO the next 100 records, which were displayed in the listview window.  Nothing difficult about that.

So there you have it.  This demonstrator can teach you a lot about using the listview control; play with it and pay attention to the events and values that GUI ScreenIO passes back to you. 

You'll be a listview expert in no time.

Related topics:


© 2000-2019 Norcom, all rights reserved 

TOC

Send feedback to Norcom