Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I need a way for all mouse down/up events to be processed by a single event handler

Posted on 2004-11-01
7
Medium Priority
?
180 Views
Last Modified: 2010-04-23
Folks:

I'm putting together a rather complicated GUI.  Basically, I want to respond to mouse move events if the left mouse button is depressed.  Thus, I want to capture mouse down and mouse up.  

What I'd lilke to do is capture the event when it happens on the menu, or any component in the menu.  I have coded:

    Private Sub cBoggleGUI_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
        If e.Button = MouseButtons.Left Then
            LeftMouseDown = True
        Else
        End If
    End Sub

This works for all mouse down events that cooure on the menu, but it does not handle any mouse downs the occure on components on the menu.

Is there a way to define an event that handles the menu, and all components?  Or do I need to program a mouse down for all of the components.  (yuc)

Ideas...
0
Comment
Question by:jflanner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 12469871
If the signatures are the same you can do something like this:

Private Sub MouseDownEvent(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown, Menu1.MouseDown, Button1.MouseDown...

Bob
0
 
LVL 5

Expert Comment

by:Ignacio Soler Garcia
ID: 12474975
Do it like this:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private WithEvents comp As Windows.Forms.Control
(...)

    Private Sub AddHandlerToControls()
        Dim index As Integer

        For index = 0 To Me.Controls.Count - 1
            AddHandler Me.Controls.Item(index).Click, AddressOf sss
        Next
    End Sub

    Public Sub sss(ByVal sender As System.Object, ByVal e As System.EventArgs)
        MsgBox("ddd")
    End Sub
End Class
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12475608
So many options, and so little feedback :(

Bob
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:Ignacio Soler Garcia
ID: 12553005
Hey jflanner, have you checked the responses?

SoMoS
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12554015
Yeah, as cleanup volunteer, I see a lot of abandoned questions.

Bob
0
 
LVL 5

Expert Comment

by:Ignacio Soler Garcia
ID: 12554342
Ok, then fire this one will be ok?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12554362
Unfortunately, I need to wait for 21 days of inactivity before closing, but that day will come soon enough :)

Bob
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question