By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,808 Members | 1,477 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,808 IT Pros & Developers. It's quick & easy.

Capture Mouse Button States and Coordinates in custom function More options

P: n/a
Is there a way to capture all relevant info about the mouse, without
using Mouse Up/Down etc. procedures?

I'm trying to make a custom function and send it the mouse info on
the
click event.
For example:
I would like to set all the controls on a form to call the same
function and within that function grab the mouse state and then
process the info....
Set all controls On Mouse Up event to "=CustomMouseFunction()"
Public Function CustomMouseFunction()
'Get the mouse info here, is there an API or does Access
provide
this info?
if (the right mouse button was clicked) then
'process
endif
End Function
I've searched the groups for suggestions, but I cant seem to find
any.
Is there an API to get the Mouse button state? or Does Access provide
this info perhaps?
Thanks in Advance

Feb 21 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Feb 21, 10:35 am, "cefran...@yahoo.com" <cefran...@yahoo.com>
wrote:
Is there a way to capture all relevant info about the mouse, without
using Mouse Up/Down etc. procedures?

I'm trying to make a custom function and send it the mouse info on
the
click event.

For example:

I would like to set all the controls on a form to call the same
function and within that function grab the mouse state and then
process the info....

Set all controls On Mouse Up event to "=CustomMouseFunction()"

Public Function CustomMouseFunction()
'Get the mouse info here, is there an API or does Access
provide
this info?
if (the right mouse button was clicked) then
'process
endif
End Function

I've searched the groups for suggestions, but I cant seem to find
any.

Is there an API to get the Mouse button state? or Does Access provide
this info perhaps?

Thanks in Advance

The Mouse events would tell you the button state, but getting the
location is a bit trickier. Access screen co-ordinates do not directly
relate to the values you'd get from an API. I'm not aware of a way to
have one function run for any control event except to call it from a
control event. In this case you would would know the control the mouse
is over.

If you must know the x,y search for the useage of GetCursorPos and
ClientToScreen APIs. You should be able to make something work from
those. Sorry, I don't have all thier details with me right now.

Feb 21 '07 #2

P: n/a
What you are trying to do - have a bunch of controls call the same
function - is best accomplished using delegages. The only problem is
that delegates is an object oriented mechanism currently not supported
in any version of Access. Here is how you would do something like that
in VB2005
]
Dim arrTxt() As TextBox

arrTxt = New Textbox(){text0, text1, text2, text3}
For Each txt As Textbox in arrTxt
AddHandler txt.Enter, AddressOf YourCustomSub
Next

For Each txt As TextBox In arrTxt
AddHandler txt.MouseClick, AddressOf MouseClick_Thing
Next

Private Sub YourCustomSub(ByVal sender As Object, ByVal e As System
EventArgs)
'--do stuff
End Sub

Private Sut MouseClick_Thing(ByVal sender As Object, e As
System.Windows.Forms.MouseEventArgs)
Console.Writeline(e.X.ToString() & " " & e.Y.ToString())
End Sub
In MouseClick_Thing you can use the e object to capture the coordinates
of the Mouse as in e.X and e.Y. There are several other properties you
can captuer for the mosue. But that is in OOP land.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Feb 21 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.