Solved

Click events with right mouse button

Posted on 1998-10-08
6
163 Views
Last Modified: 2010-05-18
if you click on a label it executes the label1_Click code, but I  then need to procede differently according to whether the click was with a left or right mouse button

Is this possible.  I know other events such as the mousedown event has a Button parameter which the click event does not - do this mean it is not possible?  If so are there any other ways  of doing the same thing - I dont want to use the mouse down event instead as I may need this for dragging and  dropping.

0
Comment
Question by:Taranadilla
6 Comments
 
LVL 2

Expert Comment

by:shchuka
ID: 1438817
I don't think there's a way to go with click event.  You have to use MouseUp event - and further check whether the mouse is within your control (if not, do not do "click" subroutine).
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1438818
Taranadilla,
In the mousedown event, you have a Button parameter.
If 0, it is the left,
1 is the right and 2 is the middle.
Regards
Dalin
0
 

Author Comment

by:Taranadilla
ID: 1438819
I know about the Button parameter in the mouse down event but as I said I am reluctant to use this event because it will preclude the use of drag and drop later.  What I am after is a way of coding the click event so that it knows about left and right mouse buttons, or an alternative way of doing the same thing.
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 9

Expert Comment

by:Dalin
ID: 1438820
Sorry, I missed the last part of the your question...I don't know how, but I just did not see the 2nd part. May be I need to get some coffee. it was 7:30 in the morning.

I am not aware of any other way that is easier than use the mousedown.  You can change the click from left to right, but I believe once it's set,  it takes it for granted.

Again, Sorry for the mistake.
0
 
LVL 1

Accepted Solution

by:
gissing earned 200 total points
ID: 1438821
The way I like to do it is to have two integer module-level variables in your form (ie in the declarations section):

Private m_iButton As Integer
Private m_iShift As Integer

In the Mouse_Down event of the control whose click event you're dealing with, just set them:

Private Sub YourControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

m_iButton = Button
m_iShift = Shift

End Sub

Then in the click event, you can do:

Private Sub YourControl_Click ()

If m_iButton = vbRightButton Then ...

End Sub


This is the only way to achieve what you want without resorting to the API. And even if you do use API calls, don't forget that by the time VB generates the click event, the mouse button has already been released.


0
 

Author Comment

by:Taranadilla
ID: 1438822
Problem solved completely - Thanks
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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