Page 1
Page 2
The PocketPC device, as other handheld devices,
has very limited screen real estate for displaying information and forms.
Microsoft has overcome this issue with many of their forms by implementing
scrollable forms. For example, they use this technique with the contact
manager entry form. This article describes a simple technique you can use
to create your own scrollable forms.

Figure 1
Figure 1 shows an example application used to enter
information on a product and stock level in a warehousing application.
A user can enter information on an item including stock location, manufacturer,
type of product, and whether it's available to ship or not. In our hypothetical
example we have iPaqs in stock, but will not ship them since our senior
executives already have their eye on them. There's more information than
can fit on one screen, but it's all very closely related. To make it easier
for a user to enter all the information quickly we want to give them access
to all the form elements at the same time. To demonstrate the scrollable
technique we'll implement our warehousing form.
To follow along, you'll need to create a form similar
to the one in Figure 2. You can add whatever control you want to, but
they will be placed within a frame (call it Frame1). First expand our
form (called Form1) to accommodate the entire size of the frame we are
creating. However, we need to make sure that the application will still
fit properly on the screen; so insure that the FormResize property is
set to vbFormFullSIPResize. Next we draw the frame on the screen and set
the BorderStyle to vbBSNone. This eliminates the caption border and provides
us a clean canvas to place our controls on. Along the side of our frame
we will place a vertical scroll bar (call it Vscroll1).

Figure 2
The frame we create should be as large as the scrollable
form we want to create. You'll notice that our sample is much larger than
the display on the PocketPC (see figure 1). You should now have Frame1
that's as large as you'll need and Vscroll1 which we'll use to scroll
the form. Finally, add the controls, such as labels and text boxes, you
need on your form.
Listing1 shows the functions needed to setup the scrollable
form. When the form is loaded, we call the setupScrollBar() which does
the bulk of the work we need to properly size and configure the scrollbar.
This subroutine first determines if the SIP keyboard is enabled. This
information is used to determine the size of the scrollbar and minimum
and maximum values of the control. The constants MINSCROLLSIZE and MAXSCROLLSIZE
control the size of the scroll bar. When the keyboard is shown, the scrollbar
is scaled down appropriately and the SmallChange and LargeChange values
are updated to allow us to consistently scroll the form. Whenever the
SIP's status changes, we execute setupScrollBar() function again. Making
the scrollbar react to the size of the displayed area makes our application
look polished and consistent to the experience the user expects.
Next Page