Connecting Tech Pros Worldwide Forums | Help | Site Map

Mouse location

EggHead
Guest
 
Posts: n/a
#1: Jan 22 '07
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

EggHead
Guest
 
Posts: n/a
#2: Jan 22 '07

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
J French
Guest
 
Posts: n/a
#3: Jan 23 '07

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
Shell
Guest
 
Posts: n/a
#4: Jan 23 '07

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

Dean Earley
Guest
 
Posts: n/a
#5: Jan 23 '07

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
Egghead
Guest
 
Posts: n/a
#6: Feb 13 '07

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 Visual Basic 4 / 5 / 6 bytes