Do I want TPageScroller or is something else required?


The application is to use a touch screen display.

Several parts of the system require the user to type in things which are then used to match entries in a list.

The display shows 0-9 and A-Z in a QWERTY style layout.

There is also SPACE and DELETE.

This works fine for any list entry which only has these characters. The display also disables unrequired buttons.


Say the list contains (this is an example list I am using and not the real data which comes from a DB) ...


The code realises that from this short list, the first letter ('a') is the only choice, so it will "accept" that automatically.
Then, the letters 'b', 'c', 'd' and 'g' are next. These are enabled and the rest disabled.
As the user chooses a letter, by pressing the appropriate button, the list is reworked from the master list to provide a speed search mechanism. It deals with entries like "acos" and "acosh" properly. And the delete works too.

As the letters are chosen they are shown in an edit box. If there is only 1 choice then this is taken automatically.

But, some entries include other symbols, not all of which are known at design time (and they can add more).



What I want to do is have an scrollable area between the ZXCVBNM line and the SPACE button which contains the available symbols as they appear (the letters are enabled/disabled to avoid mistyping).

I thought that the TPageScroller with a series of buttons in it would work, but I cannot work out how to get it to function.

The buttons are all the same width.

Does anyone have any example code (dfm and pas please) that demonstrates the usage of this control?


Is there an better/easier way of getting an unknown number of buttons into a left-right scrolling area that can be operated in a touch screen environment. Ideally, buttons to scroll left and right would be the thing.

I know I could physically build this by having a TScrollBox, but this ends up a LOT more work when I think all I need is a working example of the TPageScroller.

I know with the TPageScroller I am going to be creating the buttons are runtime,


Richard Quadling.
LVL 40
Richard QuadlingSenior Software DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

did you tried a ScrollBox?
Russell LibbySoftware Engineer, Advisory Commented:

Here is a small piece of example code that shows how you can build a scrollable
list of buttons at runtime using the pagescroller control. You have to do nothing more than place a TPageScroller on your form, then call the CreateButtonScroller procedure, which will build a list of buttons with a one char caption.  (This procedure can be called multiple times as well.)

Hope this helps,

// Sample code

procedure CreateButtonScroller(PageScroller: TPageScroller; ButtonList: Array of Char; Callback: TNotifyEvent);
var  pnlChild:   TPanel;
     btnChild:   TButton;
     dwSpacer:   Integer;
     dwIndex:    Integer;

  // Free any current child of the page scroller
  if Assigned(PageScroller.Control) then PageScroller.Control.Free;

  // Create child container window for page scroller control
  with pnlChild do
     if (PageScroller.Orientation = soHorizontal) then
        Width:=(Succ(High(ButtonList)) * Height)+dwSpacer
        Height:=(Succ(High(ButtonList)) * Width)+dwSpacer;

  // Assign the buttons
  for dwIndex:=0 to High(ButtonList) do
     if (PageScroller.Orientation = soHorizontal) then
        btnChild.SetBounds(dwSpacer, 0, pnlChild.Height, pnlChild.Height);
        Inc(dwSpacer, Succ(pnlChild.Height));
        btnChild.SetBounds(0, dwSpacer, pnlChild.Width, pnlChild.Width);
        Inc(dwSpacer, Succ(pnlChild.Width));
     // Handle the &, which will get mucked
     if (ButtonList[dwIndex] = '&') then
     // Set the child visibility
     // Wire up the button handler


procedure TForm1.OnSpecialButtonClick(Sender: TObject);

  ShowMessage((Sender as TButton).Caption);


procedure TForm1.Button1Click(Sender: TObject);

  CreateButtonScroller(PageScroller1, ['$', '%', '@', '^', '&'], OnSpecialButtonClick);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Richard QuadlingSenior Software DeveloperAuthor Commented:
WOW. Mr Smarty Pants wins.


Having got it working, it looks quite ugly.

Is there a way to preserve locations for the arrows and a some way to either control the stepping to be the width of a button or slow down the scroll speed.

Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Richard QuadlingSenior Software DeveloperAuthor Commented:

On the OnScroll event, there is a var Delta. This controls the amount of change!
Richard QuadlingSenior Software DeveloperAuthor Commented:
So. Having done all of that, I don't really like the control now.

I've done it with the TScrollBox without the hscrollbar and have 2 additional buttons (btn_Left, btn_Right).

Very useful code all the same though (Saved me having to work out adding buttons on the fly!)


Russell LibbySoftware Engineer, Advisory Commented:

I know what you mean about the control....
The pager control  really never took off big, one of the common controls that you don't see used very often at all. Glad the other piece of code was a help though

Hi RQuadling,

you could save some time if followed my advice from the beginning. :)
Richard QuadlingSenior Software DeveloperAuthor Commented:
I didn't want to use that component as I have to do the scrolling manually.

And my question was about the TPageScroller.

As requested:
'Q.: '-Is there an better/easier way of... '
'A.: '-did you tried a ScrollBox?'
'-I've done it with the TScrollBox... ' !!!

unfare, but... whatever  

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.