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

Discussion in 'Programming General' started by Covey, Apr 30, 2011.

Easy to to obtain the true X & Y position of your form?
  1. Unread #1 - Apr 30, 2011 at 1:17 PM
  2. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

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

    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?
     
  3. Unread #2 - May 3, 2011 at 3:50 PM
  4. Flopper
    Joined:
    Feb 28, 2011
    Posts:
    42
    Referrals:
    0
    Sythe Gold:
    0

    Flopper Member

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

    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? :)
     
  5. Unread #3 - May 5, 2011 at 6:20 AM
  6. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

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

    nope that is just what i was after, thanks heaps :D
     
  7. Unread #4 - May 6, 2011 at 10:01 AM
  8. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

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

    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.
     
  9. Unread #5 - May 6, 2011 at 10:57 AM
  10. Flopper
    Joined:
    Feb 28, 2011
    Posts:
    42
    Referrals:
    0
    Sythe Gold:
    0

    Flopper Member

    Easy to to obtain the true X & Y position of your 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 ;)
     
  11. Unread #6 - May 6, 2011 at 12:22 PM
  12. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

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

    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 ;)
     
< Just starting. Need advice! | * SwiftScreen BETA Released! * Screen Shot / Auto-Crop / Image Conversion >

Users viewing this thread
1 guest


 
 
Adblock breaks this site