Join
the community
Sign-up
Ask a question »

VB6 - Locating the absolute position of the mouse.

April 2013


[VB6 ] Locating the absolute position of the mouse




This feature allows you to know exact the position of the mouse from the screen and irrelevant from the sheet or control it contains.

The Module

Declaring the function


Public Type POINTAPI 
        x As Long 
        y As Long 
End Type 
Public m_CursorPos As POINTAPI 

Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Creating the function


Sub GetCursor() 
Dim LonCStat As Long 
    LonCStat = GetCursorPos&(m_CursorPos) 
    'to use this result, the data must be converted into Pixel 
. 
    m_CursorPos.x = m_CursorPos.x * Screen.TwipsPixelX 
    m_CursorPos.y = m_CursorPos.y * Screen.TwipsPixelY 
End Sub

See also

Knowledge communities.

Published by jak58
This document entitled « VB6 - Locating the absolute position of the mouse. » from Kioskea (en.kioskea.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.
Receive our newsletter

health.kioskea.net

VB6/VBA - The CommonDialog control
VB6: Modifying the image of the desktop