473,401 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Obtaining control under mouse

Hello Group

In the old days i'ev created a VB6 appl. that was able to obtain the
underlaying control under the mouse pointer. I would very much like to do
that in a C# application. I'll use VS2005 and .Net 2.0

I'll know of the solution to code each control for the mouse over event, but
I cant use that i this case.

Any one outthere with som examples?

Kind regards
Johnny Jensen
Nov 14 '06 #1
4 11736
"Johnny Jensen" <je*@aaa.dkwrote in message
news:uK**************@TK2MSFTNGP03.phx.gbl...
Hello Group

In the old days i'ev created a VB6 appl. that was able to obtain the
underlaying control under the mouse pointer. I would very much like to do
that in a C# application. I'll use VS2005 and .Net 2.0

I'll know of the solution to code each control for the mouse over event,
but I cant use that i this case.

Any one outthere with som examples?
interate through the controls collection and attach the mousemove event for
every control and then use Control.GetChildAtPoint in the event to find the
control the mouse it over.

Michael
Nov 14 '06 #2
Hey Michael

Thanks for replying and it gave me some hint, but mabye i'am a bit slow
here.

Say that i'll have a label control on my form in the rectangle 20,20,120,36
on the forms mousemove event I read the x any y values to get the point, but
the secund i reach the label the forms mousemove no longer runs - now it is
the labels mousemove event that runs, and the reading of x,y will now be
wrong.

So that way i'll never get the Control.GetChildAtPoint to be anything else
but null. but if i'll in the forms mousemove event get the x,y and look at
x+1,y-1 ( or something like that ) i'll get the control when i'am almost
over the label.

Could you give me some more hints?

Kind regards
Johnny Jensen
"Michael C" <no****@nospam.comwrote in message
news:eJ**************@TK2MSFTNGP04.phx.gbl...
"Johnny Jensen" <je*@aaa.dkwrote in message
news:uK**************@TK2MSFTNGP03.phx.gbl...
>Hello Group

In the old days i'ev created a VB6 appl. that was able to obtain the
underlaying control under the mouse pointer. I would very much like to do
that in a C# application. I'll use VS2005 and .Net 2.0

I'll know of the solution to code each control for the mouse over event,
but I cant use that i this case.

Any one outthere with som examples?

interate through the controls collection and attach the mousemove event
for every control and then use Control.GetChildAtPoint in the event to
find the control the mouse it over.

Michael

Nov 15 '06 #3

"Johnny Jensen" <je*@aaa.dkwrote in message
news:ec**************@TK2MSFTNGP06.phx.gbl...
Hey Michael

Thanks for replying and it gave me some hint, but mabye i'am a bit slow
here.

Say that i'll have a label control on my form in the rectangle
20,20,120,36 on the forms mousemove event I read the x any y values to get
the point, but the secund i reach the label the forms mousemove no longer
runs - now it is the labels mousemove event that runs, and the reading of
x,y will now be wrong.

So that way i'll never get the Control.GetChildAtPoint to be anything else
but null. but if i'll in the forms mousemove event get the x,y and look at
x+1,y-1 ( or something like that ) i'll get the control when i'am almost
over the label.

Could you give me some more hints?
You can do:

MouseMove += Form_MouseMove;
foreach (Control c in Controls)
c.MouseMove += Form_MouseMove;

then in
void Form_MouseMove(object sender, MouseEventArgs e)
sender is the control beneath the mouse (you can surely cast it to Control),
and e will contain the relative coordinates to the upper left of sender.
>
Kind regards
Johnny Jensen
"Michael C" <no****@nospam.comwrote in message
news:eJ**************@TK2MSFTNGP04.phx.gbl...
>"Johnny Jensen" <je*@aaa.dkwrote in message
news:uK**************@TK2MSFTNGP03.phx.gbl...
>>Hello Group

In the old days i'ev created a VB6 appl. that was able to obtain the
underlaying control under the mouse pointer. I would very much like to
do that in a C# application. I'll use VS2005 and .Net 2.0

I'll know of the solution to code each control for the mouse over event,
but I cant use that i this case.

Any one outthere with som examples?

interate through the controls collection and attach the mousemove event
for every control and then use Control.GetChildAtPoint in the event to
find the control the mouse it over.

Michael


Nov 15 '06 #4
"Johnny Jensen" <je*@aaa.dkwrote in message
news:ec**************@TK2MSFTNGP06.phx.gbl...
So that way i'll never get the Control.GetChildAtPoint to be anything else
but null. but if i'll in the forms mousemove event get the x,y and look at
x+1,y-1 ( or something like that ) i'll get the control when i'am almost
over the label.

Could you give me some more hints?
In addition to what Ben said, you should add label1.x and label1.y to your x
and y values.

Michael
Nov 19 '06 #5

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

Similar topics

1
by: Andrew Grothe | last post by:
I'm trying to upgrade a VB 6 App to VB.NET and I'm getting an error message that there is no license file for commondialog control. Does anyone know how to get the license file or know of a...
4
by: simo | last post by:
I'm looking to make an app to record my mouse movements and play them back. It will essentially be for unit testing websites, so I suppose it could be done using one of the wxPython MSIE ActiveX...
0
by: Qwert | last post by:
Heya, I have a user control (inherits from listview control). I add a textbox control to it as a child control and give the child control the focus. All is well when I type text (keyboard input)...
3
by: blue_nirvana | last post by:
Is there a way to determine what TabPage the mouse pointer is at, either on the mouse enter of the TabControl or TabPage? I'm simply wanting to determine the TabPage that the mouse is over. Does...
3
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...
2
by: ahmed.maryam | last post by:
Hello Everyone, I designed a custom control that is entirely covered by a picture box. I then dragged this custom control onto a windows form application (called main) and I need to handle mouse...
3
by: Spam Catcher | last post by:
Hi all, I'm having some trouble with the Mouse Hover/Leave events on a user control. Say I have a user control with a panel covering the whole control. In turn, a label + picture box cover...
10
by: Glich | last post by:
hi, how can I, control mouse position and clicking from python? I want to interact with a flash application inside firefox. thanks. ps: I am not using windows.
1
by: RobcPettit | last post by:
Hi Ive added a usercontrol to a form. When I hover over the control with the mouse, it shows the timer icon, but my control is just a layout and Im not actively updateting it. If I come of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
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,...
0
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...

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.