Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Center on 800*600 and 640*480

Posted on 1999-01-19
5
Medium Priority
?
160 Views
Last Modified: 2010-04-06
How can I center a button on a screen of 640*480, 800*600 and 1024*768 pixels.

Thanks a lot,
Vincent

0
Comment
Question by:Vincentg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 30 total points
ID: 1362443
put the following on  form resize or form create:

procedure TForm1.FormResize(Sender: TObject);
begin
with Button1 do begin
Left:=(Parent.Width - Width) div 2;
Top :=(Parent.Height - Height) div 2;
end;
end;

Regards Barry
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1362444
Use this instead:
  with Button1 do SetBounds( (Parent.Width - Width) div 2, (Parent.Height - Height) div 2, Width, Height );
  or...
  with Button1 do SetBounds( (Screen.Width - Width) div 2, (Screen.Height - Height) div 2, Width, Height );

/// John
0
 
LVL 17

Expert Comment

by:inthe
ID: 1362445
erajoj
why you say "use this instead" setbounds position is identical to my method on all sized screens/forms???
Regards Barry
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1362446
Vincent, if you've Delphi4, just use the anchor property to bind the component to each border...

Barry, if you set "left" and "top" seperately, the buttons is moved/updated/redrawed/checked/blabla/blabla two times.
If you call SetBounds, the button is only xxx one time.
I'm not sure, but I think, changing e.g. Left ends up in a call like this:
  SetBounds(newLeft,top,width,height);

Regards, Madshi.
0
 

Author Comment

by:Vincentg
ID: 1362447
I want to thank all for there comments.

Vincent

0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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