William Benson (VBACreations.Com)
vbacreations at gmail.com
Tue Jul 5 07:01:19 CDT 2011
I tried your code A.D., it works pretty well.
It occasionally misses when the button's edge is near the top (but not at
the top) of its section and when another control is near the button's edge..
But it's great, thank you.
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D. Tejpal
Sent: Tuesday, July 05, 2011 5:10 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] How to tell a button's "air space" is nolonger
beinghovered over
Bill,
Apparently, in view of special positioning of control in question, you
are looking for a solution that is self contained within control's MouseMove
event. You could experiment with sample code given below:
' Code in form's module
'==============================
' Declarations section
Private gX As Single, gY As Single
'---------------------------------------------
Private Sub CmdTest_MouseMove( _
Button As Integer, _
Shift As Integer, _
X As Single, Y As Single)
With Me.CmdTest
Me.CmdTest.Caption = "Test (MM)"
If gX <> 0 Then
If (X > (0.9 * .Width) And X > gX) _
Or (X < (0.1 * .Width) And _
X < gX) Then
Me.CmdTest.Caption = "Test"
End If
End If
If gY <> 0 Then
If (Y > (0.9 * .Height) And Y > gY) _
Or (Y < (0.1 * .Height) And _
Y < gY) Then
Me.CmdTest.Caption = "Test"
End If
End If
End With
gX = X
gY = Y
End Sub
'==============================
Normal caption of command button named CmdTest is "Test". When mouse
pointer is brought over it, the caption changes to "Test (MM)". As & when
the mouse pointer moves away from the control, the caption reverts back to
normal, i.e. "Test".
Note:
(a) MouseMove event fires in rapid-fire style. Values for X and Y
returned by this event have a range from 0 upto the width and height (in
twips) of the control in question.
(b) The multiplying factors of 0.9 and 0.1 used in the sample code could
perhaps be fine tuned further (say 0.95 and 0.05) so as to narrow down the
twilight zone. However a coarser setting as adopted above, is found
conducive to more consistent behavior. This is because a deliberately wild
mouse sweep by the user can result in X or Y value getting truncated short
of the potential maximum, even though the mouse pointer has moved out.
Best wishes,
A.D. Tejpal
------------
----- Original Message -----
From: William Benson (VBACreations.Com)
To: 'Access Developers discussion and problem solving'
Sent: Monday, July 04, 2011 20:53
Subject: Re: [AccessD] How to tell a button's "air space" is nolonger
beinghovered over
A.D.,
Other controls are too near the button's bottom and it's top edge is
pretty
much as .Top = 0.
I have put the code in the other controls already, similar to what you
wrote.
I was wondering if there was a way like to test the mousemove if the
coordinates are exactly on bottom or top or at either side of the button,
based on X, Y, or whatever... and if so, the caption is treated as if the
mouse were outside it, and if not, use the caption that pertains to the
moust being inside. During a normal mousemove operation the user will be
headed out or headed into the interior of the button, so
-- if on the way out, the last code to execute will be to reset the
caption
-- if on the way in, the code executing (probably continuously) will be
to
set the caption appropriate for interior of button
But I don't think it is possible to get the event to faithfully fire
exactly
as the mouse is going over the edge of the button.
Thanks a lot,
Bill
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of A.D. Tejpal
Sent: Monday, July 04, 2011 10:23 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] How to tell a button's "air space" is no longer
beinghovered over
William,
For detecting whether the mouse pointer has moved away from the
control
in question, you can use the MouseMove event of form section to which the
said control belongs, for example:
' Code in form's module
'=============================
Private Sub Detail_MouseMove( _
Button As Integer, Shift As Integer, _
X As Single, Y As Single)
' <<Your Code>>
End Sub
'--------------------------------------------
Private Sub FormFooter_MouseMove( _
Button As Integer, Shift As Integer, _
X As Single, Y As Single)
' <<Your Code>>
End Sub
'--------------------------------------------
Private Sub FormHeader_MouseMove( _
Button As Integer, Shift As Integer, _
X As Single, Y As Single)
' <<Your Code>>
End Sub
'=============================
Best wishes,
A.D. Tejpal
------------
----- Original Message -----
From: William Benson (VBACreations.Com)
To: 'Access Developers discussion and problem solving'
Sent: Sunday, July 03, 2011 01:23
Subject: [AccessD] How to tell a button's "air space" is no longer
beinghovered over
I have some code which changes the caption of a button when the user has
the ctrl key pressed, set during the mousemove event for the button.
I want however, that when the user leaves the "air space" for the
button,
then the caption reverts - regardless whether they still have shift
held.
I know I can use use the mousemove event associated with all surrounding
controls to reset it, but I would like something more related to the
control itself.
Is there a method of testing that the user has moved the mouse outside
the
button's air space?
I have a feeling I am going to be out of luck...
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com