Form Location
-
I tried getting the location from using Start Position via Centre Screen. But the results give me 0,0 for its location. How do I find its position? -- modified at 20:18 Tuesday 27th December, 2005 UPDATE: Ok, if i use centre screen, I cannot set its location differently unless I use manual, thus is there a way to find the StartPosition location somehow?
-
I tried getting the location from using Start Position via Centre Screen. But the results give me 0,0 for its location. How do I find its position? -- modified at 20:18 Tuesday 27th December, 2005 UPDATE: Ok, if i use centre screen, I cannot set its location differently unless I use manual, thus is there a way to find the StartPosition location somehow?
There you go: //"this" refers to the current form object Point somePoint = this.PointToScreen(Location); //Note it calculates it from upper-left edge of the client area, not the border. I don't think there is a specific function to do that, but you can easily calculate it if you want the location of the form from the border. This is the width and height of the border in pixels: {X=3,Y=29}. Of course if you have tool border (smaller) it will be different. If you want to check that set the form start position to manual like so: this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; This will make your form/dialog box open in the upper-left edge of your screen. ______________________________ |_____________________________|<- form/dialog box border ||...........................................|| ||...........................................||<- form border ||.......................<-------------||--- client area ||...........................................|| ||...........................................|| ||___________________________|| -- Don't worry about the world coming to an end today. It's already tomorrow in Australia -- -- modified at 22:34 Tuesday 27th December, 2005