I am coding a WinForms application in Visual Studio C# 2010 and I want to find out the location of the upper left corner of the WinForm window (the starting location of the window).
How can I do that?
The position of the form is determined by the Location property. The form is positioned at the Windows default location and is resized to the default size determined by Windows. The form is positioned at the Windows default location and isn't resized.
To center your form in the application screen, open the form in design view. View the Form Properties. Set the "Auto Center" property to "Yes".
Use Form. CenterToScreen() method. On system with two monitors the form will be centered on one that currently have the cursor.
When the user has the program minimized and presses F3 a global hook keys gets the press and translation window should be made and brought to front.
If you are accessing it from within the form itself then you can write
int windowHeight = this.Height;
int windowWidth = this.Width;
to get the width and height of the window. And
int windowTop = this.Top;
int windowLeft = this.Left;
To get the screen position.
Otherwise, if you launch the form and are accessing it from another form
int w, h, t, l;
using (Form form = new Form())
{
form.Show();
w = form.Width;
h = form.Height;
t = form.Top;
l = form.Left;
}
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With