Centering a form

J

JonWayn

I have searched the web for a solution on centering forms in Access but every
answer suggests using the AutoCenter property of the form. Well, in my
particular case, that doesnt work. See, I am opening a form, and in the Load
event of the form, I am adjusting the size of the form based on the amount of
text passed into the OpenArgs property, which is displayed on a label. So, to
rephrase the question:
How do I determine the new positions (Left and Top) of a form, given the
Width and Height of said form. I assume I need to somehow find the dimensions
of the screen in order to place the form, but how?

Thanks
 
R

Rick Brandt

JonWayn said:
I have searched the web for a solution on centering forms in Access but
every answer suggests using the AutoCenter property of the form. Well, in
my particular case, that doesnt work. See, I am opening a form, and in the
Load event of the form, I am adjusting the size of the form based on the
amount of text passed into the OpenArgs property, which is displayed on a
label. So, to rephrase the question:
How do I determine the new positions (Left and Top) of a form, given the
Width and Height of said form. I assume I need to somehow find the
dimensions of the screen in order to place the form, but how?

I use code from the Access 2000 Developer's Handbook, Part I by Getz,
Litwin, and Gilbert so I am not sure of the legality of posting it (so I'm
not). If you purchase a copy of that book you get a CD with it that
includes the functionality.

Basically it uses Windows API calls to determine the size of the form and
them position it. One of the choices is to center it in the Access parent
window.
 
S

Stuart McCall

JonWayn said:
I have searched the web for a solution on centering forms in Access but
every
answer suggests using the AutoCenter property of the form. Well, in my
particular case, that doesnt work. See, I am opening a form, and in the
Load
event of the form, I am adjusting the size of the form based on the amount
of
text passed into the OpenArgs property, which is displayed on a label. So,
to
rephrase the question:
How do I determine the new positions (Left and Top) of a form, given the
Width and Height of said form. I assume I need to somehow find the
dimensions
of the screen in order to place the form, but how?

Thanks

This should help you out:

http://www.smccall.demon.co.uk/Windows.htm#WinManip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top