Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Delphi 4. How to center a button on a panel?

1,188 views
Skip to first unread message

Anthony Servito

unread,
Jul 10, 1998, 3:00:00 AM7/10/98
to

Does anybody know how to center a button on a panel at runtime while form
is being shown and/or resize.
This panel is on a PageControl with tabsheets. I don't have any problem if
the tabsheet(where the panel is located) is the active sheet of the page
control - The button is in the center. But when the tabsheet is the the
active sheet the button will not be center when the tabsheet is make active
at runtime then resizing the form.

I'm using Delphi 4 and I was hoping that a property called Anchors will
help.


Richard C Haven

unread,
Jul 10, 1998, 3:00:00 AM7/10/98
to
OnResize
begin
with MyButton do
begin
Left := (Parent.Width - Width) div 2;
Top := (Parent.Height - Height) div 2;
end;
end;

Cheers

Anthony Servito

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to
Will Anchors property work?

And what if I have two buttons?


Richard C Haven <rha...@dontspamonme-santacruz.com> wrote in article
<35A69B...@dontspamonme-santacruz.com>...

Eric Harmon [TPX]

unread,
Jul 13, 1998, 3:00:00 AM7/13/98
to
Anthony,

Anchors won't work for you. It will keep the button centered, but it
will stretch it as the form grows.

-Eric Harmon

Anthony Servito

unread,
Jul 14, 1998, 3:00:00 AM7/14/98
to
So what should I do if you have 2 buttons side by side. How do I keep them
in the center if parent is resize.

tnx in advance.

Eric Harmon [TPX] <Eric....@tpx.turbopower.com> wrote in article
<35AA708F...@tpx.turbopower.com>...

Konstantin Kipa

unread,
Jul 14, 1998, 3:00:00 AM7/14/98
to
Simple way:

As I understand, you have a panel with some buttons?
Let's name this panel Panel1.

Drop on Panel1 another TPanel (Panel2) and place buttons on Panel2.
Now you can center Panel2 and dont worry about buttons.

Anthony Servito wrote in message <01bdaf30$f5456a20$110422c8@ants>...

Anthony Servito

unread,
Jul 15, 1998, 3:00:00 AM7/15/98
to
Thanks Konstantin!!!

Konstantin Kipa <ko...@crypt.rnd.ru> wrote in article
<6ofulq$3t...@forums.borland.com>...

0 new messages