Solved

exact positioning of fomr2 on form1

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Comparing dates in Delphi. Greater than/ Less than 3 368
Delphi application Soap connection 5 152
Convert GUI app into console app for Win32 Env 5 137
RESTRequest Parameter 4 81
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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