Solved

exact positioning of fomr2 on form1

Posted on 1998-03-01
2
237 Views
Last Modified: 2010-04-06
hi,

I got 2 forms, And I need to load Form2 exactly in the center of form1. So that both forms center is in the same position, any ideas?
bye
0
Comment
Question by:hellfire052497
  • 2
2 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 50 total points
ID: 1359944
In Form2 code:

--//--
implementation

uses
  Form1Unit;

procedure TForm2.Form2Create(Sender: TObject);
var
  CenterX, CenterY: Integer;
begin
  with Form1 do begin
    CenterX := Left + Width div 2;
    CenterY := Top + Height div 2;
  end;
  with Self do begin
    Left := CenterX - Width div 2;
    Top := CenterY - Height div 2;
  end;
end;
--//--

This will create Form2 centered on Form1.

HTH, julio
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1359945
As you can see, i put the code inside the OnCreate handler of Form2, but you could put it anywhere needed: OnActivate, OnShow, or even attach it to a button, so that, when you click it, Form2 gets centered on Form1.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

18 Experts available now in Live!

Get 1:1 Help Now