473,625 Members | 2,600 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.ControlEv entArgs)
AddHandler e.Control.Mouse Move, DirectCast(Chec kCursor(),
System.Windows. Forms.MouseEven tHandler)
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(ByV al e As
System.Windows. Forms.MouseEven tArgs) As Object

Thx

Nov 21 '05 #1
5 4079


Sam wrote:
Hi,

Protected Overrides Sub OnControlAdded( ByVal e As
System.Windows. Forms.ControlEv entArgs)
AddHandler e.Control.Mouse Move, DirectCast(Chec kCursor(),
System.Windows. Forms.MouseEven tHandler)
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(ByV al e As
System.Windows. Forms.MouseEven tArgs) As Object


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

AddHandler e.Control.Mouse Move, AddressOf CheckCursor

(note the AddressOf here)

and make CheckCursor have the correct signature:

Public Function CheckCursor(ByV al sender As Object, _
ByVal e As System.Windows. Forms.MouseEven tArgs) 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.ControlEv entArgs)
AddHandler e.Control.Mouse Move, AddressOf CheckCursor
End Sub

Public Function CheckCursor(ByV al sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) As Object
gives :

Method 'Public Function CheckCursor(sen der As Object, e As
System.Windows. Forms.MouseEven tArgs) As Object' does not have the same
signature as delegate 'Delegate Sub MouseEventHandl er(sender As Object,
e As System.Windows. Forms.MouseEven tArgs)'.
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.ControlEv entArgs)
AddHandler e.Control.Mouse Move, AddressOf CheckCursor
End Sub

Public Sub CheckCursor(ByV al sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs)
If Not m_chkAnchor.Che cked Then
Dim pt As New Point(e.X, e.Y)

If Not DirectCast(send er,
Control).Client Rectangle.Conta ins(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(ByV al 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
1802
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
2371
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 WM_LButtonDown WM_MButtonDown WM_RButtonDown
2
4904
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? private Boolean isCanPaint = false; private MouseEventArgs MouseEvent1;
18
2948
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. If you do have any ideas I would really like to hear them. Thanks Colin - 0 - 0 - 0 - I want a glorified popup/context menu on a button that shows only when
2
15443
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 events allowing the user control to react to the mouse click. Setting the Enabled property on the label to False comes close, but I don't want the font color to change. Does anyone have an idea how .NET implements the code behind the Enabled...
3
4907
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 "Clicks" property, but it returns always 1. Is there any chance to get "Clicks" greater than one? Thanks in advance.
4
9592
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
3549
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 excellent transforms specified on Bob Powell's site, I still wonder if there's an easier way of centering it than the following procedure? Here is what I do now (it's awkward but it works): 1) I follow the transforms specified on Bob Powell's...
2
5448
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 e.Location, but I can't work out why or what exactly the discrepancy is. My forms are all custom without title bars and thus I've had to create my own moving methods, etc. This is obviously related to the location of the mouse pointer. My mouse...
0
8182
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
8688
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
8635
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
8352
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
6115
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
5570
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
4085
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
4188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2614
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

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.