Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

centering an 'executed' form on main form? 1

Status
Not open for further replies.

CADTenchy

Technical User
Dec 12, 2007
237
GB
I have a daughter form that I am calling with the following line:
Code:
  if DetailsForm.Execute then

This daughter form has a BorderStyle property set to BsDialog, so I can read true or false if the OK or Cancel button is used to close the form in my if statement above.

I've set the Position property of this form to poMainFormCenter and also poOwnerForm Center.

Whilst this works (it centers the daughter on the parent form as I require) , it only does this on the first call of the daughter window. If I need to close it and call it again, which I do, it 'remembers' where it was last time, so if I move the parent form it is no longer centered on main form.

Can I fix this in any way?

Steve (Delphi 2007 & XP)
 
Are you releasing the instance of the DetailsForm variable in between 'executes'?
 
Not knowingly.

How would I do so?

Steve (Delphi 2007 & XP)
 
The line in my OP calls and executes the form, returning a true or false depending on if I click the OK button on it or not.
The form itself is added to project in usual way, ie, it's not created on the fly at runtime.

Steve (Delphi 2007 & XP)
 
Okay - so then you will be able to move the form before you call .execute to where you want it to be. Something like:

Code:
DetailsForm.Top := x; 
DetailsForm.Left := y;
if DetailsForm.Execute...

Ideally you should have the form center itself during on Execute if this is always the desired behaviour.

Django
 
Thanks for that. I was looking for a setting, and overlooked the obvious coding option!



Steve (Delphi 2007 & XP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top