Retrieving mouse coordinates within a client window...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • a4andy
    New Member
    • Jul 2008
    • 1

    Retrieving mouse coordinates within a client window...

    Hi,

    This has got me pulling my hair out, all I want to do is get the cursor position within a client window in the same units as the window coordinates.

    If I use;

    Code:
    Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Integer, ByRef lpRect As RECT) As Integer
    to get the coordinates of the client window and;

    Code:
    Private Structure RECT
            Dim Left As Long
            Dim Top As Long
            Dim Right As Long
            Dim Bottom As Long
        End Structure
    to store them, then;

    Code:
    Dim CR as RECT
    
    GetClientRect(m_LastHwnd, CR)
    works fine. Now when I click in the client window, I can't work out how to retrieve the cursor postion relative to the client window in the same units as the client window.

    I'm sure it can't be too hard, I'm just having trouble searching for it since most of the keywords one would use are rather common and return hundreds if not thousands of entries.

    Would appreciate any ideas or tips and am using VB.Net 2005.

    TIA

    Andy
Working...