is not a parent, is a measurement parameter that I need to do a calculation
Main Topics
Browse All TopicsHi,
I have so many buttons, about 650, I want to set a size (height and Widht) equal for all through code. Currently I do this for a button
AdvSmoothButton54.Width := Panel45.Width div 5;
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I believe you need to set the width and height of your buttons, but also Left/Top position.
If you need to arrange a lot of buttons, you have to tell us how they are positioned and how you want to arrange them. Supposing you want them in row/columns you could have a procedure like this :
LayoutControls([edit1,edit
will but say 2 edit in columns with 2 buttons underneath
>> What I need is to know just how to set the width of each button the same for all the buttons
No, if you only change the size, they will stay in their former position and overlap or have more space than necessary between them.
>> this is difficult??
no it's not, you just have to copy/paste the code provided and alter to suit your needs like space between buttons
if all your buttons must take the full width of the panel and no space between them, then alter the LayoutAllPanels like below, and call
LayoutAllPanels( Parent_Of_All_Your_Panels );
Probably my English is not very clear, further evidence to explain better, in my program I had written this
AdvSmoothButton54.Width := Panel45.Width div 5;
AdvSmoothButton246.Width := Panel45.Width div 5;
AdvSmoothButton247.Width := Panel45.Width div 5;
AdvSmoothButton248.Width := Panel45.Width div 5;
AdvSmoothButton250.Width := Panel45.Width div 5;
AdvSmoothButton236.Width := Panel45.Width div 5;
AdvSmoothButton237.Width := Panel45.Width div 5;
AdvSmoothButton238.Width := Panel45.Width div 5;
AdvSmoothButton239.Width := Panel45.Width div 5;
AdvSmoothButton240.Width := Panel45.Width div 5;
AdvSmoothButton231.Width := Panel45.Width div 5;
AdvSmoothButton232.Width := Panel45.Width div 5;
AdvSmoothButton233.Width := Panel45.Width div 5;
AdvSmoothButton234.Width := Panel45.Width div 5;
AdvSmoothButton235.Width := Panel45.Width div 5;
AdvSmoothButton241.Width := Panel45.Width div 5;
AdvSmoothButton242.Width := Panel45.Width div 5;
AdvSmoothButton243.Width := Panel45.Width div 5;
AdvSmoothButton244.Width := Panel45.Width div 5;
AdvSmoothButton245.Width := Panel45.Width div 5;
AdvSmoothButton226.Width := Panel45.Width div 5;
AdvSmoothButton227.Width := Panel45.Width div 5;
AdvSmoothButton228.Width := Panel45.Width div 5;
AdvSmoothButton229.Width := Panel45.Width div 5;
AdvSmoothButton230.Width := Panel45.Width div 5;
How can I simplify the code?
ok, I didn't knew that AdvSmoothButton has an align property. It's not the case for standard buttons.
Then do the same as explained above but simpler. I just wanted to provide a sample that could work for everything, with options.
It could even be simpler by removing some tests but it's safer this way
you made it even simpler ...
above your form paste this
type
TAdvSmoothButton = class(unitname.TAdvSmoothB
public
constructor Create(AOwner: TComponent); override;
end;
TYourForm = class(TForm)
...
public
function ButtonWidth: integer;
end;
constructor TAdvSmoothButton.Create(AO
begin
inherited Create(AOwner);
DoInitWidth;
end;
procedure TAdvSmoothButton.DoInitWid
begin
Width := TYourForm(Owner).ButtonWid
end;
function TYourForm.ButtonWidth: integer;
begin
Result := 50;
if Assigned(Panel45) then
Result := Panel45.Width div 5;
end;
Geert, you missed a point : The buttons need resize when the panel are resized. And if you want to go that way then you'd better simply state that the width of a button := TPanel(Owner).Width Div 5;
So danz67, assuming that all your panels are in the same panel (or other) parent, here is what you have to do :
add an onResize event for this parent container :
procedure TForm1.PanelResize(Sender:
begin
LayoutAllPanels(TComponent
end;
Yep, that's the simplest form of it, requiring that you only have buttons in your form that needs this kind of resize (all will be affected) and that they have all the same width. All you have to do is then to put this code in the formResize event, and call this formResize event in the onFormCreate (or after your buttons are created if dynamically) because otherwise they won't be correctly sized until you resize your forms once.
Business Accounts
Answer for Membership
by: Geert_GruwezPosted on 2009-11-04 at 00:18:01ID: 25737323
is panel45 the parent ?
or what relationship does it have to the button ?
you could add a unit code with the class and new constructor to modify all with only changing the uses ...