Solved

Do I want TPageScroller or is something else required?

Posted on 2003-12-10
9
978 Views
Last Modified: 2007-12-19
Hi.

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.

e.g.

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

abs
acos
acosh
addcslashes
addslashes
aggregate
aggregate_info

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).

e.g.
(
,
)
-
+
_

So.

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?

OR

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,

Regards,

Richard Quadling.
0
Comment
Question by:RQuadling
  • 4
  • 3
  • 2
9 Comments
 
LVL 2

Expert Comment

by:odissey1
ID: 9912585
Hi,
did you tried a ScrollBox?
odissey1
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 250 total points
ID: 9912705
Richard,

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,
Russell

// Sample code

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

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

  // Create child container window for page scroller control
  pnlChild:=TPanel.Create(PageScroller);
  with pnlChild do
  begin
     BevelOuter:=bvNone;
     BevelInner:=bvNone;
     Parent:=PageScroller;
     dwSpacer:=High(ButtonList);
     if (PageScroller.Orientation = soHorizontal) then
        Width:=(Succ(High(ButtonList)) * Height)+dwSpacer
     else
        Height:=(Succ(High(ButtonList)) * Width)+dwSpacer;
     Visible:=True;
  end;

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

end;

procedure TForm1.OnSpecialButtonClick(Sender: TObject);
begin

  ShowMessage((Sender as TButton).Caption);

end;

procedure TForm1.Button1Click(Sender: TObject);
begin

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

end;
0
 
LVL 40

Author Comment

by:RQuadling
ID: 9912891
WOW. Mr Smarty Pants wins.

Nearly.

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.



0
 
LVL 40

Author Comment

by:RQuadling
ID: 9912974
Aha!

On the OnScroll event, there is a var Delta. This controls the amount of change!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Author Comment

by:RQuadling
ID: 9912983
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!)

Thanks.

Richard.
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 9913132

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

Regards,
Russell
0
 
LVL 2

Expert Comment

by:odissey1
ID: 9913485
Hi RQuadling,

you could save some time if followed my advice from the beginning. :)
0
 
LVL 40

Author Comment

by:RQuadling
ID: 9913775
I didn't want to use that component as I have to do the scrolling manually.

And my question was about the TPageScroller.

Richard.
0
 
LVL 2

Expert Comment

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

unfare, but... whatever  

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
proper way to parse text with delphi 7 101
Base1 Encode/Decode 3 68
Convert MS Word document to a PDF file 9 64
Graphics32 under Delphi 10.1 Berlin 2 38
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now