473,500 Members | 1,605 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get mouseeventargs

Sam
Hi,

Protected Overrides Sub OnControlAdded(ByVal e As
System.Windows.Forms.ControlEventArgs)
AddHandler e.Control.MouseMove, DirectCast(CheckCursor(),
System.Windows.Forms.MouseEventHandler)
End Sub

The above code is to redirect the MouseMove event of any controls added
to my panel to the method CheckCursor. This works except that
CheckCursor needs the MouseEventArgs you would normally pass to it. How
can I get it for the current child control ?

Public Function CheckCursor(ByVal e As
System.Windows.Forms.MouseEventArgs) As Object

Thx

Nov 21 '05 #1
5 4074


Sam wrote:
Hi,

Protected Overrides Sub OnControlAdded(ByVal e As
System.Windows.Forms.ControlEventArgs)
AddHandler e.Control.MouseMove, DirectCast(CheckCursor(),
System.Windows.Forms.MouseEventHandler)
End Sub

The above code is to redirect the MouseMove event of any controls added
to my panel to the method CheckCursor. This works except that
CheckCursor needs the MouseEventArgs you would normally pass to it. How
can I get it for the current child control ?

Public Function CheckCursor(ByVal e As
System.Windows.Forms.MouseEventArgs) As Object


It looks like you have the syntax slightly muddled. I think you just
need to do a

AddHandler e.Control.MouseMove, AddressOf CheckCursor

(note the AddressOf here)

and make CheckCursor have the correct signature:

Public Function CheckCursor(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) As Object

and you are done. Note that DirectCast'ing to xxxHandler isn't really
meaningful: the procedure either has the right signature to be a
xxxHandler or it doesn't.

--
Larry Lard
Replies to group please

Nov 21 '05 #2
Sam
thx.
but it still don't work :

Protected Overrides Sub OnControlAdded(ByVal e As
System.Windows.Forms.ControlEventArgs)
AddHandler e.Control.MouseMove, AddressOf CheckCursor
End Sub

Public Function CheckCursor(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) As Object
gives :

Method 'Public Function CheckCursor(sender As Object, e As
System.Windows.Forms.MouseEventArgs) As Object' does not have the same
signature as delegate 'Delegate Sub MouseEventHandler(sender As Object,
e As System.Windows.Forms.MouseEventArgs)'.
Can you help further ?
thx

Nov 21 '05 #3
Sam
oups sorry, was just function to replace with sub...

I'm testing now.

Nov 21 '05 #4
Sam
Ok I've got the following code now :

Protected Overrides Sub OnControlAdded(ByVal e As
System.Windows.Forms.ControlEventArgs)
AddHandler e.Control.MouseMove, AddressOf CheckCursor
End Sub

Public Sub CheckCursor(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
If Not m_chkAnchor.Checked Then
Dim pt As New Point(e.X, e.Y)

If Not DirectCast(sender,
Control).ClientRectangle.Contains(pt) Then
Collapse()
End If
End If
End Sub

and in the constructor of my inherited panel control:

AddHandler Me.MouseMove, AddressOf CheckCursor

There are 3 different cases now:
-mouse moves in panel and leaves -> collapse OK
-mouse moves in child control only -> not collapse
-mouse moves in panel and then in child control and then leaves ->
collapse OK

I don't understand what';s going on here ?!?!

Nov 21 '05 #5
Sam
After debugging, I've noticed that in case the mouse moves in the panel
and then in the child control, the sender in
Sub CheckCursor(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEven*tArgs)
is still my panel instead of being the child control...
Why ?

Nov 21 '05 #6

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

Similar topics

0
1799
by: JH | last post by:
Where can I find an event handler for the wheel mouse scroll event? Is there one in the MouseEventArgs somewhere? Thanks in advance for your assistance.
1
2366
by: Rob Schoenaker | last post by:
Hi, Does anybody know how I can convert all mouse messages in the following list to their respective MouseEventArgs to pass to events handlers I need these to use a NativeWindow? WM_MouseMove...
2
4897
by: Serge Klokov | last post by:
Hi! 1. Please, help with example "paint on form by mouse" 2. Below is my example, but it clear the line after each Refresh()... how to fix? 3. How to draw the line in Mouse_Move event? ...
18
2925
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
2
15403
by: bretth | last post by:
In a VB.Net Windows Forms application, I have a user control that handles mouse events. Another section of code programmatically adds a label to the control. I would like label to ignore all...
3
4900
by: Marcin Grzębski | last post by:
Hi, I'm working on control that uses a MonthCalendar. A MonthCalendar have not a DoubleClick event, so i tried to use the events related with MouseEventArgs parameter. I was trying to check...
4
9583
by: Peted | last post by:
Hello this is the click event method of a radio button private void radioButton1_Click(object sender, EventArgs e) { }
7
3537
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
2
5414
by: ducttape | last post by:
Hello I'm busy working with an MDI parent and child forms. I've found that there is a discrepancy between the locations returned by DesktopLocation, Control.MousePosition and MouseEventArgs...
0
7134
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,...
0
7229
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...
1
6905
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
5485
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
4609
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...
0
3108
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...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
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 ...
0
311
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...

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.