Connecting Tech Pros Worldwide Help | Site Map

Mouse location

  #1  
Old January 22nd, 2007, 03:35 PM
EggHead
Guest
 
Posts: n/a
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.hWnd Then
'I cannot find any method in finding the mouse location in that Visual basic control.

End If
end sub



thanks
Egghead
  #2  
Old January 22nd, 2007, 04:15 PM
EggHead
Guest
 
Posts: n/a

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@logtechcanada.com
"EggHead" <robertlo_NO_SPAM@shaw.cawrote in message news:GH4th.773721$1T2.555065@pd7urf2no...
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.hWnd Then
'I cannot find any method in finding the mouse location in that Visual basic control.

End If
end sub



thanks
Egghead
  #3  
Old January 23rd, 2007, 08:05 AM
J French
Guest
 
Posts: n/a

re: Mouse location


On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead" <robertlo_NO_SPAM@shaw.ca>
wrote:
Quote:
>This is a multi-part message in MIME format.
>
>------=_NextPart_000_0010_01C73DFE.D4179010
>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.hWnd 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
  #4  
Old January 23rd, 2007, 09:15 AM
Shell
Guest
 
Posts: n/a

re: Mouse location


In response to the post:
On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
<robertlo_NO_SPAM@shaw.castated...and I replied:
Quote:
>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.hWnd 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
rcNormalPosition As RECT
End Type

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

Declare Function GetWindowPlacement 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(Point)

lResult = GetWindowPlacement(Me.hwnd, WinPos)

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

  #5  
Old January 23rd, 2007, 09:25 AM
Dean Earley
Guest
 
Posts: n/a

re: Mouse location


Shell wrote:
Quote:
In response to the post:
On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
<robertlo_NO_SPAM@shaw.castated...and I replied:
>
Quote:
>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.hWnd 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
rcNormalPosition As RECT
End Type
>
Declare Function GetCursorPos Lib "user32" ( _
lpPoint As POINTAPI) As Long
>
Declare Function GetWindowPlacement 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(Point)
>
lResult = GetWindowPlacement(Me.hwnd, WinPos)
>
If Point.X >= WinPos.rcNormalPosition.Left And _
Point.X <= WinPos.rcNormalPosition.Right And _
Point.Y >= WinPos.rcNormalPosition.Top And _
Point.Y <= WinPos.rcNormalPosition.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@icode.co.uk)
i-Catcher Development Team

iCode Systems
  #6  
Old February 13th, 2007, 06:35 PM
Egghead
Guest
 
Posts: n/a

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@mindspring.comwrote in message
news:smjbr2157n6m2hqdokn2eslbd2fl27cl7g@4ax.com...
Quote:
In response to the post:
On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
<robertlo_NO_SPAM@shaw.castated...and I replied:
>
Quote:
>>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.hWnd 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
rcNormalPosition As RECT
End Type
>
Declare Function GetCursorPos Lib "user32" ( _
lpPoint As POINTAPI) As Long
>
Declare Function GetWindowPlacement 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(Point)
>
lResult = GetWindowPlacement(Me.hwnd, WinPos)
>
If Point.X >= WinPos.rcNormalPosition.Left And _
Point.X <= WinPos.rcNormalPosition.Right And _
Point.Y >= WinPos.rcNormalPosition.Top And _
Point.Y <= WinPos.rcNormalPosition.Bottom Then _
PointsToMe = True
End Function
'end air code
>

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript mouse location hini answers 2 March 9th, 2007 05:22 PM
Mouse location Adriano answers 7 November 20th, 2005 09:59 PM
Mouse Location (x,y) Tracking with Left Button Down gsb answers 5 July 23rd, 2005 09:55 PM