Solved

Scroll Buttons on a Panel Up and Down (Very Urgent)

Posted on 2006-07-01
7
288 Views
Last Modified: 2010-04-05
Hello Experts,

  I have a Panel on which I need to place 20 buttons. I also have 2 buttons Up and Down. I will be able to view only 10 buttons on the Panel at a time. Now when I press the Up Button, I should be able to Scroll Up one button and similarly when I press Down I should be able to scroll Down one button. I am not supposed to use a Scroll Bar. I should be able to scroll using the Up and Down buttons only. Similarly I should be able to move Left and Right (Horizontal Scrolling). How will I be able to do this. Any ideas appreciated.

with regards,
padmaja.
0
Comment
Question by:saravananvg
7 Comments
 

Expert Comment

by:SergiuAdrian
ID: 17023552
how about moving al the bunttons <up> when you click the <up button> and <down> when pressing <down button>:

when press up:

for i:= 1 to buttonCount do
   button[i].top := button[i].top - ScrollDistance;

when press down (the only diference is you have to add the moving distance):

for i:= 1 to buttonCount do
   button[i].top := button[i].top + ScrollDistance;

if you make all buttons same size and the distance between button rows and edge/bottom of the pannel  is same you can find the ScrollDistance := TheHeightOfAButton + DistanceBetweenRows. this will make the first row disapear when click up and the last row disapear when click down.

i sugest also to verify when all rows will be invisible if click up or down. this means you have scroll to much up or to much down. but this is optional ;)
0
 
LVL 14

Expert Comment

by:Hamidreza Vakilian
ID: 17023807
Hi!

It's very simple...

assume that P1 is the main panel that you have to scroll within it. you can easily put another Panel in P1 & put your buttons on the second panel...

For scrolling you can change TOP & LEFT properties of the second panel....
Also these properties accept negative values....

Programmer-x
0
 

Expert Comment

by:SergiuAdrian
ID: 17024253
yes, if you use only 2 rows of buttons this is a good idea.
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.

 

Expert Comment

by:SergiuAdrian
ID: 17024256
or if use more rows also you can make a panel for each row an move all panels at the same time.
0
 
LVL 4

Expert Comment

by:kenpem
ID: 17026935
or split the buttons between two panels which appear in the same place on the form. Then as Up/Down is pushed, set Panel1.Visible, etc.
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 100 total points
ID: 17030945
No, you need to put a TStrollBox on your panel and make it alLeft aligned. Drop your
buttons on top of the TStcrollBox and your "scroll" buttons on the right
and everything should take care of itself.


unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    ScrollBox1: TScrollBox;
    btnUp: TButton;
    btnDown: TButton;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Button13: TButton;
    Button14: TButton;
    Button15: TButton;
    Button16: TButton;
    Button17: TButton;
    Button18: TButton;
    Button19: TButton;
    Button20: TButton;
    procedure btnUpClick(Sender: TObject);
    procedure btnDownClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.btnUpClick(Sender: TObject);
begin
  if Button1.Top < 0 then
    ScrollBox1.ScrollBy(0, ScrollBox1.Height);
end;

procedure TForm1.btnDownClick(Sender: TObject);
begin
  if Button1.Top >= 0 then
    ScrollBox1.ScrollBy(0, -ScrollBox1.Height);
end;

end.


DFM Source:
object Form1: TForm1
  Left = 282
  Top = 62
  Width = 696
  Height = 483
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 0
    Top = 0
    Width = 642
    Height = 449
    Align = alLeft
    BevelOuter = bvNone
    Caption = 'Panel1'
    TabOrder = 0
    object Panel2: TPanel
      Left = 529
      Top = 0
      Width = 113
      Height = 449
      Align = alRight
      BevelOuter = bvNone
      TabOrder = 0
      object btnUp: TButton
        Left = 11
        Top = 35
        Width = 75
        Height = 25
        Caption = 'Up'
        TabOrder = 0
        OnClick = btnUpClick
      end
      object btnDown: TButton
        Left = 11
        Top = 60
        Width = 75
        Height = 25
        Caption = 'Down'
        TabOrder = 1
        OnClick = btnDownClick
      end
    end
    object Panel3: TPanel
      Left = 0
      Top = 0
      Width = 529
      Height = 449
      Align = alClient
      BevelOuter = bvNone
      Caption = 'Panel3'
      TabOrder = 1
      object ScrollBox1: TScrollBox
        Left = 0
        Top = 0
        Width = 529
        Height = 449
        HorzScrollBar.Visible = False
        VertScrollBar.Visible = False
        Align = alClient
        BevelInner = bvNone
        BevelOuter = bvNone
        TabOrder = 0
        object Button1: TButton
          Left = 0
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button1'
          TabOrder = 0
        end
        object Button2: TButton
          Left = 105
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button2'
          TabOrder = 1
        end
        object Button3: TButton
          Left = 210
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button3'
          TabOrder = 2
        end
        object Button4: TButton
          Left = 315
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button4'
          TabOrder = 3
        end
        object Button5: TButton
          Left = 420
          Top = 0
          Width = 105
          Height = 223
          Caption = 'Button5'
          TabOrder = 4
        end
        object Button6: TButton
          Left = 0
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button6'
          TabOrder = 5
        end
        object Button7: TButton
          Left = 105
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button7'
          TabOrder = 6
        end
        object Button8: TButton
          Left = 210
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button8'
          TabOrder = 7
        end
        object Button9: TButton
          Left = 315
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button9'
          TabOrder = 8
        end
        object Button10: TButton
          Left = 420
          Top = 223
          Width = 105
          Height = 223
          Caption = 'Button10'
          TabOrder = 9
        end
        object Button11: TButton
          Left = 0
          Top = 446
          Width = 105
          Height = 223
          Caption = 'Button11'
          TabOrder = 10
        end
        object Button16: TButton
          Left = 0
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button16'
          TabOrder = 11
        end
        object Button17: TButton
          Left = 105
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button17'
          TabOrder = 12
        end
        object Button12: TButton
          Left = 105
          Top = 447
          Width = 105
          Height = 223
          Caption = 'Button12'
          TabOrder = 13
        end
        object Button13: TButton
          Left = 210
          Top = 447
          Width = 105
          Height = 223
          Caption = 'Button13'
          TabOrder = 14
        end
        object Button18: TButton
          Left = 210
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button18'
          TabOrder = 15
        end
        object Button19: TButton
          Left = 315
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button19'
          TabOrder = 16
        end
        object Button14: TButton
          Left = 315
          Top = 447
          Width = 105
          Height = 223
          Caption = 'Button14'
          TabOrder = 17
        end
        object Button15: TButton
          Left = 420
          Top = 447
          Width = 105
          Height = 223
          Caption = 'Button15'
          TabOrder = 18
        end
        object Button20: TButton
          Left = 420
          Top = 670
          Width = 105
          Height = 223
          Caption = 'Button20'
          TabOrder = 19
        end
      end
    end
  end
end

0
 
LVL 6

Author Comment

by:saravananvg
ID: 17034990
Hello Experts,

  Thanks for your suggesstions, I shall work on them and get back to you very soon.

with regards,
padmaja.
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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

920 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

12 Experts available now in Live!

Get 1:1 Help Now