How to measure form locations
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
2 posts
Page 1 of 1
The subject might not be easy to understand, but let's take an example, you're application have 2 forms, and you wanted both the forms to stick together at anywhere, anytime, so one of the form must be a reference point to the other form.
I wanted the 2nd form to be on the top left of the 1st form(reference point), so to calculate the location for the 2nd form will be like the following formula :
Form1.Location.X - Form1.size.width = Left
Form1.Location.X + Form1.size.width = Right
Form1.Location.Y + Form1.size.height = Bottom
Form1.Location.Y - Form1.size.height = Top
Here, I've pre-calculated some of the basic locations :
bottom left :
I wanted the 2nd form to be on the top left of the 1st form(reference point), so to calculate the location for the 2nd form will be like the following formula :
Code: Select all
In order to calculate other locations, here's the explanation to the formula :Form1.Location.X - Form1.size.width, Form1.Location.Y - Form1.size.height
Form1.Location.X - Form1.size.width = Left
Form1.Location.X + Form1.size.width = Right
Form1.Location.Y + Form1.size.height = Bottom
Form1.Location.Y - Form1.size.height = Top
Here, I've pre-calculated some of the basic locations :
bottom left :
Code: Select all
bottom right :
Form1.Location.X - Form1.size.width, Form1.Location.Y + Form1.size.height
Code: Select all
top left :
Form1.Location.X + Form1.size.width, Form1.Location.Y + Form1.size.height
Code: Select all
top right :
Form1.Location.X - Form1.size.width, Form1.Location.Y - Form1.size.height
Code: Select all
Form1.Location.X + Form1.size.width, Form1.Location.Y - Form1.size.height
You do not have the required permissions to view the files attached to this post.
Very nice tutorial, this is a cool thing to have in every program! Great work and welcome to the site!
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

2 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023