Mouse location

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • EggHead

    Mouse location

    Hi all,

    My development environment is VB 6.0, and my OS is winxp. I would like to know how to find the mouse location at a control when the mouse is point at that control. The problem is that the mouse "whatever" events will not fire since the mouse is hjhack by other control. Anyway, I have the following code and I can check is the mouse over the control or not, however, I cannot find out where the mouse location at that control.

    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long


    private sub mouseChecker()
    Dim pnt As POINTAPI
    Dim ConvertX As Double
    GetCursorPos pnt
    If WindowFromPoint (pnt.x, pnt.y) = Me.control1.hWn d Then
    'I cannot find any method in finding the mouse location in that Visual basic control.

    End If
    end sub



    thanks
    Egghead
  • EggHead

    #2
    Re: Mouse location



    --
    Thanks
    Robert Lo
    Application Developer
    LogTech Canada Ltd
    660, 10201 Southport Road S.W.
    Calgary, Alberta
    Canada T2W 4X9
    Email: robert.lo@logte chcanada.com
    "EggHead" <robertlo_NO_SP AM@shaw.cawrote in message news:GH4th.7737 21$1T2.555065@p d7urf2no...
    Hi all,

    My development environment is VB 6.0, and my OS is winxp. I would like to know how to find the mouse location at a control when the mouse is point at that control. The problem is that the mouse "whatever" events will not fire since the mouse is hjhack by other control. Anyway, I have the following code and I can check is the mouse over the control or not, however, I cannot find out where the mouse location at that control.

    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long


    private sub mouseChecker()
    Dim pnt As POINTAPI
    Dim ConvertX As Double
    GetCursorPos pnt
    If WindowFromPoint (pnt.x, pnt.y) = Me.control1.hWn d Then
    'I cannot find any method in finding the mouse location in that Visual basic control.

    End If
    end sub



    thanks
    Egghead

    Comment

    • J French

      #3
      Re: Mouse location

      On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead" <robertlo_NO_SP AM@shaw.ca>
      wrote:
      >This is a multi-part message in MIME format.
      >
      >------=_NextPart_000_ 0010_01C73DFE.D 4179010
      >Content-Type: text/plain;
      > charset="iso-8859-1"
      >Content-Transfer-Encoding: quoted-printable
      >
      >Hi all,
      >
      >My development environment is VB 6.0, and my OS is winxp. I would like =
      >to know how to find the mouse location at a control when the mouse is =
      >point at that control. The problem is that the mouse "whatever" events =
      >will not fire since the mouse is hjhack by other control. Anyway, I have =
      >the following code and I can check is the mouse over the control or not, =
      >however, I cannot find out where the mouse location at that control.
      >
      >Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) =
      >As Long
      >Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As =
      >Long, ByVal yPoint As Long) As Long
      >
      >
      >private sub mouseChecker()
      Dim pnt As POINTAPI
      Dim ConvertX As Double
      GetCursorPos pnt
      If WindowFromPoint (pnt.x, pnt.y) =3D Me.control1.hWn d Then
      'I cannot find any method in finding the mouse location in that =
      Look at the ScreenToClient API

      It converts a Point structure from screen coordinates to client
      coordinates

      Comment

      • Shell

        #4
        Re: Mouse location

        In response to the post:
        On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
        <robertlo_NO_SP AM@shaw.castate d...and I replied:
        >Hi all,
        >
        >My development environment is VB 6.0, and my OS is winxp. I would like to know how to find the mouse location at a control when the mouse is point at that control. The problem is that the mouse "whatever" events will not fire since the mouse is hjhack by other control. Anyway, I have the following code and I can check is the mouse over the control or not, however, I cannot find out where the mouse location at that control.
        >
        >Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
        >Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
        >
        >
        >private sub mouseChecker()
        Dim pnt As POINTAPI
        Dim ConvertX As Double
        GetCursorPos pnt
        If WindowFromPoint (pnt.x, pnt.y) = Me.control1.hWn d Then
        'I cannot find any method in finding the mouse location in that Visual basic control.
        >
        End If
        >end sub
        >
        >
        >
        >thanks
        >Egghead

        Try this (air code)

        'begin code
        Type POINTAPI
        X As Long
        Y As Long
        End Type

        Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
        End Type

        Type WINDOWPLACEMENT
        Length As Long
        flags As Long
        ShowCmd As Long
        ptMinPosition As POINTAPI
        ptMaxPosition As POINTAPI
        rcNormalPositio n As RECT
        End Type

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

        Declare Function GetWindowPlacem ent Lib "user32" ( _
        ByVal hwnd As Long, _
        lpwndpl As WINDOWPLACEMENT ) As Long

        Public Function PointsToMe() As Boolean
        Dim WinPos As WINDOWPLACEMENT
        Dim Point As POINTAPI, lResult As Long

        lResult = GetCursorPos(Po int)

        lResult = GetWindowPlacem ent(Me.hwnd, WinPos)

        If Point.X >= WinPos.rcNormal Position.Left And _
        Point.X <= WinPos.rcNormal Position.Right And _
        Point.Y >= WinPos.rcNormal Position.Top And _
        Point.Y <= WinPos.rcNormal Position.Bottom Then _
        PointsToMe = True
        End Function
        'end air code

        Comment

        • Dean Earley

          #5
          Re: Mouse location

          Shell wrote:
          In response to the post:
          On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
          <robertlo_NO_SP AM@shaw.castate d...and I replied:
          >
          >Hi all,
          >>
          >My development environment is VB 6.0, and my OS is winxp. I would like to know how to find the mouse location at a control when the mouse is point at that control. The problem is that the mouse "whatever" events will not fire since the mouse is hjhack by other control. Anyway, I have the following code and I can check is the mouse over the control or not, however, I cannot find out where the mouse location at that control.
          >>
          >Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
          >Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
          >>
          >>
          >private sub mouseChecker()
          > Dim pnt As POINTAPI
          > Dim ConvertX As Double
          > GetCursorPos pnt
          > If WindowFromPoint (pnt.x, pnt.y) = Me.control1.hWn d Then
          > 'I cannot find any method in finding the mouse location in that Visual basic control.
          >>
          > End If
          >end sub
          >>
          >>
          >>
          >thanks
          >Egghead
          >
          >
          Try this (air code)
          >
          'begin code
          Type POINTAPI
          X As Long
          Y As Long
          End Type
          >
          Type RECT
          Left As Long
          Top As Long
          Right As Long
          Bottom As Long
          End Type
          >
          Type WINDOWPLACEMENT
          Length As Long
          flags As Long
          ShowCmd As Long
          ptMinPosition As POINTAPI
          ptMaxPosition As POINTAPI
          rcNormalPositio n As RECT
          End Type
          >
          Declare Function GetCursorPos Lib "user32" ( _
          lpPoint As POINTAPI) As Long
          >
          Declare Function GetWindowPlacem ent Lib "user32" ( _
          ByVal hwnd As Long, _
          lpwndpl As WINDOWPLACEMENT ) As Long
          >
          Public Function PointsToMe() As Boolean
          Dim WinPos As WINDOWPLACEMENT
          Dim Point As POINTAPI, lResult As Long
          >
          lResult = GetCursorPos(Po int)
          >
          lResult = GetWindowPlacem ent(Me.hwnd, WinPos)
          >
          If Point.X >= WinPos.rcNormal Position.Left And _
          Point.X <= WinPos.rcNormal Position.Right And _
          Point.Y >= WinPos.rcNormal Position.Top And _
          Point.Y <= WinPos.rcNormal Position.Bottom Then _
          PointsToMe = True
          End Function
          'end air code
          Bare in mind that this will also return true if the OPs window is not on
          top.

          To Egghead (why can't people use sensible names?):
          What is it that has captured the mouse as it is broken...

          --
          Dean Earley (dean.earley@ic ode.co.uk)
          i-Catcher Development Team

          iCode Systems

          Comment

          • Egghead

            #6
            Re: Mouse location

            Hi all,

            using this API "GetWindowRect" , I found it is very easy.
            The mouse event is not broken. It is because other control has the mouse
            event

            cheers,
            Egghead
            "Shell" <drshell@mindsp ring.comwrote in message
            news:smjbr2157n 6m2hqdokn2eslbd 2fl27cl7g@4ax.c om...
            In response to the post:
            On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
            <robertlo_NO_SP AM@shaw.castate d...and I replied:
            >
            >>Hi all,
            >>
            >>My development environment is VB 6.0, and my OS is winxp. I would like to
            >>know how to find the mouse location at a control when the mouse is point
            >>at that control. The problem is that the mouse "whatever" events will not
            >>fire since the mouse is hjhack by other control. Anyway, I have the
            >>following code and I can check is the mouse over the control or not,
            >>however, I cannot find out where the mouse location at that control.
            >>
            >>Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI)
            >>As Long
            >>Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As
            >>Long, ByVal yPoint As Long) As Long
            >>
            >>
            >>private sub mouseChecker()
            > Dim pnt As POINTAPI
            > Dim ConvertX As Double
            > GetCursorPos pnt
            > If WindowFromPoint (pnt.x, pnt.y) = Me.control1.hWn d Then
            > 'I cannot find any method in finding the mouse location in that
            >Visual basic control.
            >>
            > End If
            >>end sub
            >>
            >>
            >>
            >>thanks
            >>Egghead
            >
            >
            Try this (air code)
            >
            'begin code
            Type POINTAPI
            X As Long
            Y As Long
            End Type
            >
            Type RECT
            Left As Long
            Top As Long
            Right As Long
            Bottom As Long
            End Type
            >
            Type WINDOWPLACEMENT
            Length As Long
            flags As Long
            ShowCmd As Long
            ptMinPosition As POINTAPI
            ptMaxPosition As POINTAPI
            rcNormalPositio n As RECT
            End Type
            >
            Declare Function GetCursorPos Lib "user32" ( _
            lpPoint As POINTAPI) As Long
            >
            Declare Function GetWindowPlacem ent Lib "user32" ( _
            ByVal hwnd As Long, _
            lpwndpl As WINDOWPLACEMENT ) As Long
            >
            Public Function PointsToMe() As Boolean
            Dim WinPos As WINDOWPLACEMENT
            Dim Point As POINTAPI, lResult As Long
            >
            lResult = GetCursorPos(Po int)
            >
            lResult = GetWindowPlacem ent(Me.hwnd, WinPos)
            >
            If Point.X >= WinPos.rcNormal Position.Left And _
            Point.X <= WinPos.rcNormal Position.Right And _
            Point.Y >= WinPos.rcNormal Position.Top And _
            Point.Y <= WinPos.rcNormal Position.Bottom Then _
            PointsToMe = True
            End Function
            'end air code
            >

            Comment

            Working...