473,799 Members | 3,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Jan 22 '07 #1
5 7789


--
Thanks
Robert Lo
Application Developer
LogTech Canada Ltd
660, 10201 Southport Road S.W.
Calgary, Alberta
Canada T2W 4X9
Email: ro*******@logte chcanada.com
"EggHead" <ro************ **@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
Jan 22 '07 #2
On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead" <ro************ **@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
Jan 23 '07 #3
In response to the post:
On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
<ro************ **@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

Jan 23 '07 #4
Shell wrote:
In response to the post:
On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
<ro************ **@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 (de*********@ic ode.co.uk)
i-Catcher Development Team

iCode Systems
Jan 23 '07 #5
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" <dr*****@mindsp ring.comwrote in message
news:sm******** *************** *********@4ax.c om...
In response to the post:
On Mon, 22 Jan 2007 15:25:26 GMT, "EggHead"
<ro************ **@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

Feb 13 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2906
by: Jay | last post by:
I need to be able to move a Panel on a windows Form at run time using the mouse. I have tried adding a MouseDown event handler to the Panel and then within the MouseDown handler adding a MouseMove event to the Panel and then setting the Panel's Location to a new Point(x, y) with x and y set to the mouse's x and y, but this does not work because the MouseDown event of Panel only sends the cords of the mouse within that Panel. I need to be...
2
21465
by: Robin Senior | last post by:
Hi, I'm trying to drag and drop onto a Panel on my form. The panel is inside a groupBox, which of course is inside my form. When dropping the item onto my Panel, I want it to appear at that point on the Panel, and therefore need the mouse coordinates relative to the Panel and not the form itself. Something like: private void myPanel_DragDrop(object sender, DragEventArgs e) {
4
2256
by: Raj Chudasama | last post by:
I have a controls similiar to the windows calculator. (Please press some buttons on your calculator to see what i am talking about) So when u hover over a button it will change the state (it changes to different image) if u click it will show pressed image etc now the problem: the calculator does the following
5
3723
by: Charles Law | last post by:
Sorry for reposting this question, but I did not get a single answer last time, and I'm sure you guys must have some thoughts on the matter. I have a user control which can be dragged and dropped onto a form in my application when it is running. I allow it to be clicked and dragged to a new location on the form. However, the user control has a check box on it, and if the user clicks over the checkbox to drag the user control, the check...
3
2076
by: jcrouse | last post by:
I have created a form designer type application (with a lot of you peoples helpJ). It has label controls that are draggable at runtime. The user is also allowed to change some properties such as forecolor, backcolor and font. The labels also are rotatable and the text can also be flipped 180 degrees (the flipped text part is still being worked on). I have one context menu for all 30 labels that allows for the property changes to the labels....
13
3157
by: Lars Netzel | last post by:
Hi! I have a round area which I want to be able to move the mouse over and fire off events... how do I do that? I have drawn a FillPie Graphics and I feel that there has to be a way of getting to know if the mouse is over that area since I have the coordinates to paint the Pie but I don't know where to start or what to look for really. Best Regard
2
5015
by: Sam | last post by:
Hi, I can't figure out how to detect when my mouse cursor leaves a panel control. It should not trigger the event (or do anything) when the mouse leave the panel but still is over a control that is contained by the panel. I've done this : Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) If Cursor.Position.X > Me.Location.X + Me.Width Or Cursor.Position.Y > Me.Location.Y + Me.Height _
1
1766
by: beatsoup | last post by:
Is there a way to find out the location of the mouse when an event object is not handy? For example, let's say I want to wake up in 1 second and check where the mouse is. The function called by the interval timer won't have an event object. How would the routine determine the location of the mouse in that case? Thanx for any information.
2
19594
by: quickcur | last post by:
Hi, I have html like this: <div id="myCanvas" style="border:10px, black;position:relative;height:250px;width:100%;"> <img id="p" src="p.jpg"> </div> When user click the mosue, I would like 1. Test if the mouse location is on top of the image
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9544
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10238
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.