Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

exact positioning of fomr2 on form1

Posted on 1998-03-01
2
Medium Priority
?
256 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
[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
  • 2
2 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 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