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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RUNTIME CENTERING OF CONTROLS

Status
Not open for further replies.

castor2003

Programmer
Jul 5, 2003
115
0
0
LC
I am writing a dynamic form that has to be readjusted in size and Height given the parameters passed to it. This means that I would have to be centering them horizontally. Any idea how I could achieve this?
I am getting grey hair over this.
 
I am thinking this thru.

After the form is sized - based on the parameters...

1. If you take the width of your form and subtract the width of your object, and then divide that by 2. Make it an integer number. That should give you the left position.

Do the same for the height (subtract and divide by 2) and that should give you your top.

Do this in the init event.
Then set the top / left positions using:
thisform.cmdbutton.top = lnTop
thisform.cmdbutton.Left = lnLeft

Jim Osieczonek
Delta Business Group, LLC
 
HI

If the centering has to take place when the form is started, set the AUTOCENTER property of the form to .T.

If it has to be centered, whenever the form is resized,
in the forms RESIZE event, add the code,
ThisForm.AutoCenter = .t.
Also put the same code in the Moved event as well.
This will ensure that the form cannot be moved.

:)


ramani :)
(Subramanian.G)
 
Hi
A small correction..

In the ResizeEvent of the form.. you have to put

DODEFAULT() && This was left out in my previous post.
ThisForm.Autocenter = .t.

In the MovedEvent
ThisForm.AutoCenter = .t.

In the forms property..
AutoCenter = .t.
OR
in the InitEvent
ThisForm.AutoCenter = .t.

:)

ramani :)
(Subramanian.G)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top