See the Ref1.PDF  for Details on Scroll Bar

Here r some guidelines...
1. hasScrollBar attribute is to b set by programatically.
2. For Tables, Only vertical scrolling is possible.
3. U have to handle the Up/Dwn buttons of ScrollBar...
4. All the events of Scrolling should be handled by programatically...
5. some guding code... just to show how to handle the scrolling.. thats
it...
U'll have to change/write as per ur need...


static void PrvFormUpdateScroller (FormPtr frm)
{
     Word                     scrollPos;
     Word                     textHeight;
     Word                     fieldHeight;
     Short               maxValue;
     FieldPtr       fld;
     ScrollBarPtr   bar;

     fld = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, PrvFieldID));
     bar = FrmGetObjectPtr (frm, FrmGetObjectIndex (frm, PrvScrollerID));

     FldGetScrollValues (fld, &scrollPos, &textHeight,  &fieldHeight);

     if (textHeight > fieldHeight)
          maxValue = textHeight - fieldHeight;
     else
          maxValue = 0;

     SclSetScrollBar (bar, scrollPos, 0, maxValue, fieldHeight-1);
}

static void PrvFieldPageScroll (DirectionType direction)
{
     Short value;
     Short min;
     Short max;
     Short pageSize;
     Word linesToScroll;
     FieldPtr fld;
     ScrollBarPtr bar;

     fld = PrvGetObjectPtr (PrvFieldID);

     if (FldScrollable (fld, direction)) {
          linesToScroll = FldGetVisibleLines (fld) - 1;
          FldScrollField (fld, linesToScroll, direction);

          // Update the scroll bar.
          bar = PrvGetObjectPtr (PrvScrollerID);
          SclGetScrollBar (bar, &value, &min, &max, &pageSize);

          if (direction == up)
               value -= linesToScroll;
          else
               value += linesToScroll;

          SclSetScrollBar (bar, value, min, max, pageSize);
          return;
          }
}



static void PrvFieldScroll (SWord linesToScroll)
{
     Word                blankLines;
     Short                    min;
     Short                    max;
     Short                    value;
     Short                    pageSize;
     FieldPtr            fld;
     ScrollBarPtr   bar;

     fld = PrvGetObjectPtr (PrvFieldID);

     if (linesToScroll < 0) {
          blankLines = FldGetNumberOfBlankLines (fld);
          FldScrollField (fld, -linesToScroll, up);

          // If there were blank lines visible at the end of the field
          // then we need to update the scroll bar.
          if (blankLines) {
               // Update the scroll bar.
               bar = PrvGetObjectPtr (PrvScrollerID);
               SclGetScrollBar (bar, &value, &min, &max, &pageSize);
               if (blankLines > -linesToScroll)
                    max += linesToScroll;
               else
                    max -= blankLines;
               SclSetScrollBar (bar, value, min, max, pageSize);
               }
          }

     else if (linesToScroll > 0)
          FldScrollField (fld, linesToScroll, down);

}


Boolean FormHandleEvent (EventPtr event)
{
     FormPtr             frmP;
     Boolean             handled = false;


     if (event->eType == keyDownEvent) {

          if ( event->data.keyDown.chr == pageUpChr ) {
               PrvFieldPageScroll (up);
               handled = true;
               }

          else if ( event->data.keyDown.chr == pageDownChr ) {
               PrvFieldPageScroll (down);
               handled = true;
               }

          else {
               frmP = FrmGetActiveForm ();
               FrmHandleEvent (frmP, event);
               PrvFormUpdateScroller (frmP);
               if ( event->data.keyDown.chr == linefeedChr )
                    PrvProcessCommand();
               handled = true;
               }
          }
     return (handled);
}


Rest Best in Next
MAbhijit






[EMAIL PROTECTED] on 02/17/2000 08:58:52 PM

Please respond to "Palm Developer Forum" <[EMAIL PROTECTED]>

To:   "Palm Developer Forum" <[EMAIL PROTECTED]>
cc:    (bcc: Abhijit Mhetre/LTITLPUN)

Subject:  hasScrollbar Field Attribute Question ...




Hi All,

I have seen the field attribute hasScrollbar and am now playing around with
this flag.

Unfortunately I can't get this to work and would like to ask for some
hint's
on how to use that.

I have simply set this to true programaticaly expecting a scrollbar to
appear. Obviously a wrong assumption .
I placed a scrollbar on the form and am looking for a way to associate the
scrollbar to the field.

Am I completely on the wrong track or how would I handle a field with 500
chars that must be scrollable with a scrollbar.

Any pointers/advices are greatly appreciated
Thanks in advance
Ole


--
For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palm.com/devzone/mailinglists.html








-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to