Board index » delphi » page up/page down

page up/page down

hey. i'm kindof new at this.
        but what i'm trying to do is have a lightbared menu which will span
across about 5-6 pages.
the lightbars possible movements will be up and down.

so for example i'd have

1st selection
2nd selection
3rd selection
4th selection
ect. ect.

5 pages down.
now i can't seem to get everything working. well i can't get anything
working :) i've used lightbars before but i can't get it working under
here..

could someone help me out and send me some source code. even if its not
lightbared and just a multipage type thing.. just so i can get started :)

cheers!

-- cope!

 

Re:page up/page down


You need to reprint the list when the user changes page.
(you may need CRT unit in pascal)

The 'line-number offset' is stored. When first page is shown,
the offset is 0. when the second page is shown, and
(assume one page contains 20 lines) the offset is 20.
And so on.

To print the third line of the second page:
3 + offset = 3 + 20 = 23 (the 23rd line is printed)

If the user selects the third line on the second page:
3 + offset = 3 + 20 = 23 (the user selects 23)

You need to convert between the 'list item number' and
the 'line number on the screen' very often. the
correct lines are printed to the screen, and
the user's selection is converted into the right item number.

Try to do pencil work with a list of 10 items and
a small page of 3 lines. Try to figure out how the numbers
changes from one to another.

cope <8e0opk$72...@news.eisa.net.au>...

Quote
>hey. i'm kindof new at this.
>        but what i'm trying to do is have a lightbared menu which will span
>across about 5-6 pages.
>the lightbars possible movements will be up and down.

>so for example i'd have

>1st selection
>2nd selection
>3rd selection
>4th selection
>ect. ect.

>5 pages down.
>now i can't seem to get everything working. well i can't get anything
>working :) i've used lightbars before but i can't get it working under
>here..

>could someone help me out and send me some source code. even if its not
>lightbared and just a multipage type thing.. just so i can get started :)

>cheers!

>-- cope!

Re:page up/page down


Quote
On Mon, 24 Apr 2000 16:16:27 -0000, "cope" <cop...@eisa.net.au> wrote:
>hey. i'm kindof new at this.
>        but what i'm trying to do is have a lightbared menu which will span
>across about 5-6 pages.
>the lightbars possible movements will be up and down.

>so for example i'd have

>1st selection
>2nd selection
>3rd selection
>4th selection
>ect. ect.

>5 pages down.
>now i can't seem to get everything working. well i can't get anything
>working :) i've used lightbars before but i can't get it working under
>here..

>could someone help me out and send me some source code. even if its not
>lightbared and just a multipage type thing.. just so i can get started :)

>cheers!

>-- cope!

Program ManyMenus;
{Each menu is stored as a record in a file of records which can then
be accessed by record number 0.. and displayed. The action to be taken
upon selection is identified by the record number and the menu item,
whether selected by a highlight bar, numerically or by alphabetical
char.

In order to read various numbers of selections on each menu, it is
suggested that an array be used within each record all of which are
initialized to '' so this can be used as a terminator for that
specific menu. Only the simple computer made menus are shown here. The
selection method and logic are left to you.}

CONST max = 20;      {Up to 20 items per menu, arbitrary}
      last = 10;     {10 menu selections/menu here for demo}
      source = 'MYMENU.DAT';
TYPE
s70 = String[70];
menuItems = Record
               A:Array[1..max] of s70;
            End;
VAR
menu:menuItems;
ct, j, k:Byte;
f:File of menuItems;
select:String[2];

Procedure ShowMenu(mnum:Byte);
VAR n:Byte;
Begin
     Writeln;
     Seek(f, mnum);
     Read(f, menu);
     n := 1;
     While menu.A[n] <> '' Do
     Begin
          Writeln(n:2, '. ', menu.A[n]);
          Inc(n);
     End;
     Write('Press Enter ':30);  Readln;
End;

BEGIN
     Assign(f, source);
     Rewrite(f);
     For j := 0 to 5 Do
     Begin
          For ct := 1 to max Do menu.A[ct] := ''; {initialize}
          For k := 1 to last Do
          Begin
           Str(j, menu.A[k]);  {'0'..'5'}
           Str(k, select);     {'1'..'10'}
           menu.A[k] := 'Menu ' + menu.A[k] + ', selection ' + select;
          End;
          Write(f, menu);
     End;

     ShowMenu(2); {arbitrary random selection}

     For j := 0 to 5 Do ShowMenu(j);   {sequential selection}
     Close(f);
END.

Other Threads