Hello folks,

OK, I'm going to ask it:

How do you display a list (not a field), scrollable with a scrollbar control 
instead of with the standard puny arrows?

Yes, I know. It has been asked zillions of times in the past. A search of the 
archives of this forum returned more than 100 matches. I've read them all. 
Unfortunately, none of them provided sufficient information to answer this 
question. Like, you know, a detailed tutorial on how it is done.

So far, I have understood the following:

1) The proper way to get rid of the puny arrows is by telling LstSetListChoices 
that the list has only as many elements as would fit on the screen (or less). 
Fiddling with the hasScrollBar attribute of the control is *not* a proper way 
to do it. Unfortunately, if you do that, you can no longer scroll the list with 
calls to LstScrollList.

2) In order to circumvent the above problem, you have to intercept any scroll 
movements, compute what part of the list should be displayed as a result of the 
scroll, and draw only that part of the list with LstSetListChoices.

3) You must also update the scroll bar "manually" by calling SclSetScrollBar 
with parameters reflecting where in the list you're supposed to be.

4) You must intercept sclRepeatEvent, which occurs when the user drags the 
scrollbar, must get the scrollbar's position with SclGetScrollBar, and must 
update the list to look accordingly with LstSetListChoices and LstDrawList.

5) There are some third-party libraries (usually in C++) that make implementing 
such a control easy. Unfortunately, that's not good enough for me; my project 
must be in pure C and can't rely on third-party libraries.

6) Making a scrollbar-scrollable table is even more difficult than making such 
a list.

Well, that's the theory. Unfortunately, I still can't figure out how to 
implement it in practice. :-(

I've searched the Web and while I've found many applications that do use such a 
feature (so, obviously many developers know how to do it), and many people 
asking how to do it, I couldn't find a good, descriptive answer with sample 
code. :-(

Among other things, it is still not clear to me:

1) What events should you intercept? sclRepeatEvent, obviously; lstSelectEvent, 
if you want to do something when an element of the list is selected; probably 
keyDownEvent, if you want to scroll with the hard key too. Anything else? Like 
penDownEvent, penUpEvent - to detect when exactly you're hitting the control?

2) When the user taps an element on the list and drags the stilus up or down 
outside the boundaries of the list, the list scrolls. What kind of event occurs 
then?

The closest thing to a working example that I have found is this:

http://news.palmos.com/read/messages?id=51356

Its author actually says that it doesn't work properly and is asking for help 
(nobody answered). I implemented something based on it, but it sitll has lots 
of problems:

1) The puny arrows are still there. Of course, because the list is scrollable - 
the code relies on LstScrollList.

2) It needs to have the whole list in memory, instead of reading from a 
database only the part that has to be visible.

3) Scrolling the list by dragging the stilus up or down isn't reflected on the 
scroll bar (because I don't know which event to catch, in order to detect such 
an action).

Help, anyone? A good tutorial on this subject is sorely needed...

Regards,
Vesselin
-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to