• Log in or sign up for an account here: https://www.sythe.org/login

Easy to to obtain the true X & Y position of your form?

Covey

Creator of EliteSwitch

Retired Sectional Moderator
Visual Basic Programmers
Joined
Sep 9, 2005
Sythe Gold
9
Messages
4,510
Age
17
Location
Fuckin' BAM!
Is there is easy way to obtain the TRUE X and Y position of your form relative to the screen?
Code:
me.bounds.left 'or .x
Just if you you're forms X position including the border...i just need the clientsize's X. (inside the border).

I have made a work around by a rather long winded math formula using clientsize.width and me.width etc

But was just wondering if there was a simpler way?
 
I'm unaware of the depths of your question, so I was rather hesitant in offering a simple solution, but I'll start out nonetheless:
* Have you paid attention to PointToScreen? That'd go:

Code:
Dim screenCoordinates as Point = PointToScreen(FormName.Location)

If this isn't what you were looking for; could you elaborate? :)
 
I'm unaware of the depths of your question, so I was rather hesitant in offering a simple solution, but I'll start out nonetheless:
* Have you paid attention to PointToScreen? That'd go:

Code:
Dim screenCoordinates as Point = PointToScreen(FormName.Location)

If this isn't what you were looking for; could you elaborate? :)

nope that is just what i was after, thanks heaps :D
 
My mistake, it still seems to be off by a few pixels.
What i'm trying to do is get the x y co-ordinate of the ACTUAL form not the border of the form.

How about overriding the OnPaint of the form and taking the ClipRectangle? I can't test it right on this PC and I don't know enough about it to tell you if it's the correct way. Try it out and see if it gives you the desired results, though.

Make a global variable somewhere and override the OnPaint of the form:
Code:
Public Class Form1
    Public paintpoint As Point

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)

        paintpoint = e.ClipRectangle.Location
    End Sub
End Class

.. and take the PointToScreen of the paintpoint variable.

If that doesn't work, I can't help you, unless I look further into it ;)
 
How about overriding the OnPaint of the form and taking the ClipRectangle? I can't test it right on this PC and I don't know enough about it to tell you if it's the correct way. Try it out and see if it gives you the desired results, though.

Make a global variable somewhere and override the OnPaint of the form:
Code:
Public Class Form1
    Public paintpoint As Point

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaint(e)

        paintpoint = e.ClipRectangle.Location
    End Sub
End Class

.. and take the PointToScreen of the paintpoint variable.

If that doesn't work, I can't help you, unless I look further into it ;)

It's all good mate, i nutted it out :D
i just put a control in the top corner of the form and got the pointtoscreen of that :D

Thanks for the help ;)
 
Runescape Gamblingrunescape gambling
Back
Top