Solved

Click events with right mouse button

Posted on 1998-10-08
6
162 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

919 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now