Hi everyone,
I have a scrollbar to scroll a table in my program.
In my form event handler, I catch event sclRepeat and
based on the differences between the old value of the
scroll bar and the new value, I adjust the scrollbar
accordingly. This works well user taps on the arrows,
or move the scroll car slowly or one step at a time.
However, when the user drags the scroll car quick a
drop it, it always goes back to the initial position,
and the screen is not updated.
Could you please share your experience on this matter
?
Or if you know if there are any books or examples,
please point me into the right direction.
Thanks!
This is the code that I have in my program:
case sclRepeatEvent:
MainViewScroll(eventP->data.sclRepeat.newValue -
eventP->data.sclRepeat.value);
void MainViewScroll (Int16 linesToScroll)
{
TablePtr tableP;
Int16 rowsInTable, scrollAmount,
lastRow;
UInt16 newTopVisibleRecord,i;
WinDirectionType direction;
RectangleType scrollP, vacated;
FormPtr frmP;
frmP = FrmGetActiveForm();
tableP = (TablePtr)GetObjectPtr (MainPyroTable);
rowsInTable = TblGetNumberOfRows (tableP);
newTopVisibleRecord = topVisibleRecord;
selectedRecord = noRecordSelected;
TblUnhighlightSelection(tableP);
// Scroll the table down.
if(linesToScroll > 0) // Scroll down
newTopVisibleRecord = topVisibleRecord + 1;
// Make the next record to be the top visible one
else if (linesToScroll < 0) // Scroll up
newTopVisibleRecord = topVisibleRecord - 1;
// Make the previous record to be the top visible one
topVisibleRecord = newTopVisibleRecord;
// Move the portion that remains visible according
to the specified direction
if (((linesToScroll > 0) && (linesToScroll <
rowsInTable)) ||
((linesToScroll < 0) && (-linesToScroll <
rowsInTable))) {
scrollAmount = 0;
if (linesToScroll > 0) { // Scroll down
lastRow = TblGetLastUsableRow(tableP) - 1;
for (i=0; i<linesToScroll; i++) {
scrollAmount += TblGetRowHeight(tableP,
lastRow);
TblRemoveRow(tableP, 0);
//TblMarkTableInvalid(tableP);
}
direction = winUp;
}
else if (linesToScroll < 0) { // Scroll up
for(i=0; i<-linesToScroll; i++) {
scrollAmount +=TblGetRowHeight(tableP,0);
TblInsertRow(tableP,0);
//TblMarkTableInvalid(tableP);
}
direction = winDown;
}
TblGetBounds(tableP, &scrollP);
WinScrollRectangle(&scrollP, direction,
scrollAmount, &vacated);
WinEraseRectangle(&vacated, 0);
}
MainViewLoadTable(frmP,topVisibleRecord);
TblRedrawTable(tableP);
}
=====
Best regards,
Van Nguyen.
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/