473,782 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Determine the Control under the mouse cursor

How can I determine the control under the mouse cursor when a user
muves the mouse?? For example if the user moves the cursor over a
textbox i would receive the name of that textbox without using the
"MouseMove" event for that textbox.

Thanks

Nov 21 '05 #1
6 8670
"Andrea V.F." <vf******@gmail .com> schrieb:
How can I determine the control under the mouse cursor when a user
muves the mouse?? For example if the user moves the cursor over a
textbox i would receive the name of that textbox without using the
"MouseMove" event for that textbox.


Take a look at the form's 'GetChildAtPoin t' method. You can determine the
current cursor position using 'Cursor.Positio n'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
Your suggestion works if a component is on a Form, but not if the
component is on a Panel (as in my case).

Thanks for help.

Nov 21 '05 #3


Andrea V.F. wrote:
Your suggestion works if a component is on a Form, but not if the
component is on a Panel (as in my case).


If the control returned from Form.GetControl AtPoint is a container
control, then you need to call *its* GetControlAtPoi nt method, and so
on recursively until you end up with a control that isn't a container,
or Nothing, which means you are on a blank part of the container. Make
sure to transform your Point appropriately on the way down.

It might be easier to hook up all your form's controls' MouseMove event
to a single event handler.

--
Larry Lard
Replies to group please

Nov 21 '05 #4
if I call the GetControlAtPoi nt of the panel I receive always Nothing
even if I'm on a control into the panel.

What do you mean with "Make
sure to transform your Point appropriately on the way down."

Nov 21 '05 #5
"Andrea V.F." <vf******@gmail .com> schrieb:
if I call the GetControlAtPoi nt of the panel I receive always Nothing
even if I'm on a control into the panel.

What do you mean with "Make
sure to transform your Point appropriately on the way down."


'Control.PointT oClient' et al. The control's 'GetControlAtPo int' method
expects control coordinates, not screen coordinates.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6


Herfried K. Wagner [MVP] wrote:
"Andrea V.F." <vf******@gmail .com> schrieb:
if I call the GetControlAtPoi nt of the panel I receive always Nothing
even if I'm on a control into the panel.

What do you mean with "Make
sure to transform your Point appropriately on the way down."


'Control.PointT oClient' et al. The control's 'GetControlAtPo int' method
expects control coordinates, not screen coordinates.


I was gonna say that and I had a nice sample ready, but my sample
doesn't work! I have a nice recursive routine that takes screen
coordinates and returns the control in that position - BUT - when do I
call it? Form.MouseMove is no use as it isn't called when not
*directly* on the form; and I think we wanted to avoid hooking to every
MouseMove event?

Confused.

--
Larry Lard
Replies to group please

Nov 21 '05 #7

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

Similar topics

3
17311
by: Csaba2000 | last post by:
I have set onmousedown to change the cursor, but this setting is ignored (IE 5.5; NN 6.1 on Win 2K Pro) until the mouse is either moved or the mouse button is released. On Opera 7.01, the setting seems to be ignored completely, even when I try with window.setTimeout. So my two questions are: (1) Most important: Is there anything I can do so that I don't have to wait for the next mouse event before the cursor gets repainted. (2) Why...
15
10949
by: Tinus | last post by:
Hello all, I've created a custom control that draws a monthly schedule (using the Draw function in C#). Basically it draws 31 boxes and writes the day number in every box. This works great. But I now want to show a different tooltip for every day. For now I found out that I can add a tooltip for the entire custom control
3
7536
by: Blaz Ziherl | last post by:
I have this control that has no MouseEnter or MouseLeave events. How could I find out whether the mouse cursor is over that control or not? Is there an equivalent to the WindowFromPoint API function available in VB.NET? Regards, Blaz Ziherl blaz.ziherl@abraxas.si
2
5012
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 _
3
8916
by: Wayne Wengert | last post by:
In VB.NET is there a way to set the mouse cursor to the Wait cursor that will stay in effect across several forms? For example, I want to set the cursor to the WaitCursor in formA just before it calls formB and FormB may, in turn, call another form. I want the WaitCursor until control is returned to formA where I reset it to Default. (I believe that in VB6 there was the notion of a screen cursor - that is what I want) TIA Wayne
1
3060
by: celoftis | last post by:
BACKGROUND: I have some PPT slides that have been converted to HTM (ensuring that the show slide animations while browsing checkbox is checked). The original HTM slides have custom animations to allow movie (wmv) playback on mouse click. (All animations have been verified to work when viewing slides in ppt.) Further, I have ensured that the converted HTM file(s) contain only relative file paths. SITUATION #1 When I open the converted...
0
2131
by: NonNB | last post by:
Hi I have a user control which the user can "drag" across the screen (I'm not using "real" .NET drag drop - instead a single click flavour, where the control is drawn at the mouse position). Depending on whether the user has "picked up" the control or not, I need the following behaviour 1) When the control is being dragged, the control must not intercept
1
32487
Ericks
by: Ericks | last post by:
This must be a piece of cake and I'm sure it has been addressed somewhere in this forum. I have a form with a control that when clicked on opens another form. So I want the cursor to change to a hand cursor when moving over the control like with a hyperlink, making it easy to spot for the user (I guess you saw this one coming). In Access 2007 I could simply make the control a hyperlink with the "always" attribute, and the hand cursor appears...
0
1574
vekipeki
by: vekipeki | last post by:
Does anyone know if there is a way to set a custom mouse cursor for an ActiveX control in .Net? I am adding some mouse functionality to an existing ActiveX control, and would like to change the cursor shape according to the current state. It's a Windows Forms app, with an ActiveX control wrapped in the (automatically generated) class (derived from AxHost). Although AxHost is derived from Windows.Forms.Control, the public Cursor property does...
0
10313
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...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10081
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,...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
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
5378
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.