472,958 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 11704
"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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.