Results 1 to 7 of 7

Thread: cursor position

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2001
    Posts
    283

    cursor position

    how do I get the cursor position in relation to a specified control?

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. MousePosition.X and MousePosition.Y

  3. #3
    Hyperactive Member
    Join Date
    Mar 2004
    Location
    Prato - Tuscany - Italy
    Posts
    461
    Almost surely, Pirate gave you what you needed, but if you wanted to know where the blinking cursor is, for example, in a textbox:

    Dim goofy As Byte = Me.TextBox1.SelectionStart

    Excuse me for my english!
    Live long and prosper (Mr. Spock)

  4. #4

    Thread Starter
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    that gives it to me relative to the screen dosn't it pirate? what if I want it in relation to a listview, for example?

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Then use PointToClient function to get coordinates within client area (not in the whole screen)

    like this
    VB Code:
    1. Dim pnt As Point = Me.ListView1.PointToClient(New Point(MousePosition.X, MousePosition.Y))
    2.         MessageBox.Show(pnt.ToString)

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    You might need to check the difference between the previous code and this one . Here we used the form's PointToClient function not the control's .
    VB Code:
    1. Dim pnt2 As Point = Me.PointToClient(New Point(MousePosition.X, MousePosition.Y))

  7. #7

    Thread Starter
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    yeah, thanks pirate.

    pointToClient is the way to go.

    -marvin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width