Connecting Tech Pros Worldwide Forums | Help | Site Map

Catch right click of mouse

Newbie
 
Join Date: Mar 2008
Posts: 2
#1: Mar 4 '08
I am at present working on integration of help functions in my Access data base.

My intention is simply to make a right click on an object (including labels) to open a specific help topic.

In a form I can enable the KeyPreview to catch any keystroke even if an object has focus.

My questions are:

1. Can a similar function be implemented for the mouse ?

2. How to detect whether it was a Right Click?

3. How to detect which object the mouse pointed at when the Right click occurred (easy when dealing with objects which can get focus - but does not include labels) ?

I do appriciate the possibility to use the OnMouseDown event using Button for detection of Right Click but I would prefer if possible to have a code module which handles everything on form level instead of code for each individual object.

NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#2: Mar 6 '08

re: Catch right click of mouse


Interesting question.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_MouseDown(Button As Integer, _
  2.                            Shift As Integer, _
  3.                            X As Single, _
  4.                            Y As Single)
  5. End Sub
Above (changed formatting for ease of viewing) is what Access does for you on the form's MouseDown event.
This seems to have the info you need. Be careful though! Check in the help system for when the events trigger for the form and when they trigger for other items on the form (controls; sections; etc).

Good luck.
Newbie
 
Join Date: Mar 2008
Posts: 2
#3: Mar 10 '08

re: Catch right click of mouse


Thank's NeoPa - sorry for late response - my ASP decided that I should live without internet for some days.

Mousedown on a form is OK but only if the mouse pointer is outside any of the controls on the form.

My alternative is to use F1 and the form keypreview - that works fine except for the fact that Access Help pops up after my own code.

Any way to avoid that?
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,730
#4: Mar 10 '08

re: Catch right click of mouse


I'm afraid you're getting into rare territory for me :(
I will just say what I believe to be the case, and let you check the help file for further details.
  1. I believe the MouseDown can be triggered for the form alone under certain conditions. I'm not sure what they are but I think the Help system explains further.
  2. I believe there is a way in the KeyPreview event procedure to cancel the keystroke (any further keystroke processing). Again, check out the help system for further details.
Reply