MouseMove event help

D

dchendrickson

I am using Access2002/XP Pro and programming primarily
with ADO structures.

I have some forms that are populated with MANY toggle
buttons (they represent wiring connection on a circuit
card). I want to use the mouse move event to update the
Caption of the toggle buttons.

Since each toggle button uses exactly the same code, I
wrote a single function procedure and call to that
instead of the toggle_MouseMove() event procedure.

The problem is how to let the code know which toggle
button is calling it. I am trying to avoid updating the
call for each toggle button individually because that
would mean opening and editing literally hundreds. My
first approach was:

On Mouse Move....... =MouseMoveTimerSet([ActiveControl])

where MouseMoveTimerSet is my Function Procedure. But
[ActiveControl] sends a reference to whichever control
has the focus. So is there a simple way to pass reference
to which control is triggering the code?

The other solution I am trying to avoid (again because of
the shear number of toggle buttons) is to call my
function from the event procedure of each toggle.

Thanks in advance.

-dc
 
T

TC

MouseMove exposes the X & Y coordinates, no? (I don't have Access here to
check.) Perhaps you could do a calculation based on those, to determine
which toggle the cursor was over. O, on the open even of the form, execute
some code which determines the toggle positions (in MouseMove X/Y coordinate
values) and stores them in an array, for subsequent use by a
coordinates-to-toggle translation procedure? Seems awfully ugly, though...

HTH,
TC
 
A

Assaf

TC: this won't work because MouseMove for the form doesn't fire when over a
control and DC doesn't want to trap every control's MouseMove event.

DC: if your objection to coding every control's MouseMove is the sheer
labor, you might consider automating the creation of code using the Module
object, esp. CreateEventProc and InsertLines methods. You can iterate
through the controls on the form, identify the ToggleButtons and enter code
for each MouseMove event.

It'd work something like this:
* Iterate through controls: For each ctrl in Forms!MyForm.Controls
* Identify ToggleButtons: If TypeOf ctrl Is ToggleButton Then
* Create MouseMove Event procs: lngReturn =
mdl.CreateEventProc("MouseMove", ctrl.Name)
* Enter your code: mdl.InsertLines lngReturn + 1, "ctrl.caption =
""something"""

It only looks daunting, but I've done this very successfully in similar
scenarios. You can get fancy and create an Add-In if you're feeling
adventurous.

HTH

-Assaf

TC said:
MouseMove exposes the X & Y coordinates, no? (I don't have Access here to
check.) Perhaps you could do a calculation based on those, to determine
which toggle the cursor was over. O, on the open even of the form, execute
some code which determines the toggle positions (in MouseMove X/Y coordinate
values) and stores them in an array, for subsequent use by a
coordinates-to-toggle translation procedure? Seems awfully ugly, though...

HTH,
TC


dchendrickson said:
I am using Access2002/XP Pro and programming primarily
with ADO structures.

I have some forms that are populated with MANY toggle
buttons (they represent wiring connection on a circuit
card). I want to use the mouse move event to update the
Caption of the toggle buttons.

Since each toggle button uses exactly the same code, I
wrote a single function procedure and call to that
instead of the toggle_MouseMove() event procedure.

The problem is how to let the code know which toggle
button is calling it. I am trying to avoid updating the
call for each toggle button individually because that
would mean opening and editing literally hundreds. My
first approach was:

On Mouse Move....... =MouseMoveTimerSet([ActiveControl])

where MouseMoveTimerSet is my Function Procedure. But
[ActiveControl] sends a reference to whichever control
has the focus. So is there a simple way to pass reference
to which control is triggering the code?

The other solution I am trying to avoid (again because of
the shear number of toggle buttons) is to call my
function from the event procedure of each toggle.

Thanks in advance.

-dc
 
D

dchendrickson

Assaf,

Thanks for the suggestion/confirmation. While stewing
about the predicament I was in and waiting for an
enlightened answer from this forum, I had come accross
the module.createeventproc help topic. My brain was
beginning to orgainize an approach just as you have
suggested. I have already written one-time-use utility
code to cycle through all of the forms' toggle buttons
for misc. updating.

Thanks for your input.

-dc
-----Original Message-----
TC: this won't work because MouseMove for the form doesn't fire when over a
control and DC doesn't want to trap every control's MouseMove event.

DC: if your objection to coding every control's MouseMove is the sheer
labor, you might consider automating the creation of code using the Module
object, esp. CreateEventProc and InsertLines methods. You can iterate
through the controls on the form, identify the ToggleButtons and enter code
for each MouseMove event.

It'd work something like this:
* Iterate through controls: For each ctrl in Forms! MyForm.Controls
* Identify ToggleButtons: If TypeOf ctrl Is ToggleButton Then
* Create MouseMove Event procs: lngReturn =
mdl.CreateEventProc("MouseMove", ctrl.Name)
* Enter your code: mdl.InsertLines lngReturn + 1, "ctrl.caption =
""something"""

It only looks daunting, but I've done this very successfully in similar
scenarios. You can get fancy and create an Add-In if you're feeling
adventurous.

HTH

-Assaf

MouseMove exposes the X & Y coordinates, no? (I don't have Access here to
check.) Perhaps you could do a calculation based on those, to determine
which toggle the cursor was over. O, on the open even of the form, execute
some code which determines the toggle positions (in
MouseMove X/Y
coordinate
values) and stores them in an array, for subsequent use by a
coordinates-to-toggle translation procedure? Seems awfully ugly, though...

HTH,
TC


I am using Access2002/XP Pro and programming primarily
with ADO structures.

I have some forms that are populated with MANY toggle
buttons (they represent wiring connection on a circuit
card). I want to use the mouse move event to update the
Caption of the toggle buttons.

Since each toggle button uses exactly the same code, I
wrote a single function procedure and call to that
instead of the toggle_MouseMove() event procedure.

The problem is how to let the code know which toggle
button is calling it. I am trying to avoid updating the
call for each toggle button individually because that
would mean opening and editing literally hundreds. My
first approach was:

On Mouse Move....... =MouseMoveTimerSet ([ActiveControl])

where MouseMoveTimerSet is my Function Procedure. But
[ActiveControl] sends a reference to whichever control
has the focus. So is there a simple way to pass reference
to which control is triggering the code?

The other solution I am trying to avoid (again because of
the shear number of toggle buttons) is to call my
function from the event procedure of each toggle.

Thanks in advance.

-dc


.
 
T

TC

TC: this won't work because MouseMove for the form doesn't fire when over a
control and DC doesn't want to trap every control's MouseMove event.

Oops! You're right. Thanks for the correction. It is important for
misleading advice to be corrected, so people who follow it do not go off on
the wrong track.

TC

(snip)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top