Solved

exact positioning of fomr2 on form1

Posted on 1998-03-01
2
243 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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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