I have button
I want to add shadow only when hover
How I do it?
Sorry to disagree but the Shadow property has in fact been available since Access 2010 when Quick Styles were introduced.
However, like the rest of the Quick Styles items, it isn't shown in the button's control sheet
The syntax is either CommandButtonName.Properties("Shadow") or just CommandButtonName.Shadow
So for example, if you have a button called Command0, you can use code like this on the button's mouse move event: - Private Sub Command0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Me.Command0.BorderColor = vbRed 'add a red border
-
Me.Command0.Properties("Shadow") = 1 'add a drop shadow at bottom right (or try 18 or 22)
-
End Sub
-
You will then need to remove that code when you move away from the button so use code like this in the form's Detail_MouseMove event: - Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Me.Command0.BorderColor = RGB(132, 161, 198) 'restore blue border
-
Me.Command0.Properties("Shadow") = 0 'remove shadow
-
End Sub
-
I have attached a simple example demonstrating the use of the above code.
Also, see the Microsoft Help article: CommandButton.Shadow property 5 6686 NeoPa 32,554
Expert Mod 16PB
In simple terms you would have the shadow turned off by design and then turn it on & off within the Event procedure for the form's Move event, depending on the latest position of the pointer as reported.
Unfortunately, when I looked in my 2019 version, I found no way to turn shadowing on or off :-(
I also had difficulties making sense of the Form_MouseMove documentation on Microsoft's web site. I left a comment to that effect but couldn't get it to work even to change the size of the font :-(
However, I will keep this flagged and attempt to find out more for you. Watch this space.
In the meantime, the basic logic should be something like the following which I knocked up to test : - Option Compare Database
-
Option Explicit
-
-
Private Const conCB As String = "cmdTest"
-
-
Private Sub Form_MouseMove(Button As Integer, Shift As Integer _
-
, X As Single, Y As Single)
-
Dim lngFS As Long
-
-
With Me
-
With .Controls(conCB)
-
If X < .Left Or X > .Left + .Width _
-
Or Y < .Top Or Y > .Top + .Height Then
-
lngFS = 11
-
Else
-
lngFS = 15
-
End If
-
If .FontSize <> lngFS Then .FontSize = lngFS
-
End With
-
End With
-
End Sub
You can ask questions about this once you've read & tried to understand it.
Here's the basic design of the form. Very simple with a Button control in the middle of an otherwise empty form with a 1cm gap on all sides. NeoPa 32,554
Expert Mod 16PB
I now learn, from a few of the other Access MVPs who generously chipped in to help me understand this better, that each object (Section, Command Button, etc.) needs to be handled by its own OnMouseMove event procedure.
I also learned that there is a .Shadow property - but which wasn't available in my version A2019 :-( CommandButton.Shadow property (Access) explains how it needs to be set for the various different possible options. In my code below I'll use the value 1 to set it and 0 to clear it. - Option Compare Database
-
Option Explicit
-
-
Private Const conCB As String = "cmdTest"
-
-
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer _
-
, X As Single, Y As Single)
-
With Me.Controls(conCB)
-
If .Shadow <> 0 Then .Shadow = 0
-
End With
-
End Sub
-
-
Private Sub cmdTest_MouseMove(Button As Integer, Shift As Integer _
-
, X As Single, Y As Single)
-
With Me.Controls(conCB)
-
If .Shadow <> 1 Then .Shadow = 1
-
End With
-
End Sub
Note that, even though one of the event procedures is set specifically for the Command Button object itself, the code still needs to use the name of the object in order to reference it when setting it's Shadow property - hence line #4 where it's set as a constant.
Sorry to disagree but the Shadow property has in fact been available since Access 2010 when Quick Styles were introduced.
However, like the rest of the Quick Styles items, it isn't shown in the button's control sheet
The syntax is either CommandButtonName.Properties("Shadow") or just CommandButtonName.Shadow
So for example, if you have a button called Command0, you can use code like this on the button's mouse move event: - Private Sub Command0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Me.Command0.BorderColor = vbRed 'add a red border
-
Me.Command0.Properties("Shadow") = 1 'add a drop shadow at bottom right (or try 18 or 22)
-
End Sub
-
You will then need to remove that code when you move away from the button so use code like this in the form's Detail_MouseMove event: - Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Me.Command0.BorderColor = RGB(132, 161, 198) 'restore blue border
-
Me.Command0.Properties("Shadow") = 0 'remove shadow
-
End Sub
-
I have attached a simple example demonstrating the use of the above code.
Also, see the Microsoft Help article: CommandButton.Shadow property NeoPa 32,554
Expert Mod 16PB
Hi isladogs.
Before I continue I should add that he was indeed one of the other Access MVPs who steered me in the right direction on the .Shadow property earlier. Thanks for that again :-)
I'm happy for you to disagree on when it was introduced. I'd rather be shown up than steer anyone incorrectly. I'd made an assumption as to the cause of my not seeing it but that appears incorrect. I tried to check but the documentation had nothing on it I could find.
As for the use of the .Shadow property, I have since updated the code to show what I'd meant before. The text explains the situation correctly but I'd forgotten to change the code from my own testing and I'd used different font sizes to test the concept worked before posting. As you can see I used the simpler second alternative that you show rather than using the .Properties() collection.
Hi NeoPa
That's better! Your corrected code does indeed work.
For the benefit of the OP, using the simplest version of the code as in my post #4 will cause screen flicker as the code will repeatedly update the appearance every time the mouse moves. To prevent that, add code (as @NeoPa did in post #3) to first check the current state of the button so the changes only occur once. My variation on that idea is: - Private Sub Command0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
-
'check current state of control so it only changes once
-
If Not Me.Command0.BorderColor = vbRed Then Me.Command0.BorderColor = vbRed 'add a red border
-
-
If Not Me.Command0.Shadow = 1 Then Me.Command0.Shadow = 1 'add a drop shadow at bottom right (or try 18 / 22 etc)
-
End Sub
-
-
Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
-
'check current state of control so it only changes once
-
If Not Me.Command0.BorderColor = RGB(132, 161, 198) Then Me.Command0.BorderColor = RGB(132, 161, 198) 'restore blue border
-
-
If Not Me.Command0.Shadow = 0 Then Me.Command0.Shadow = 0 'remove shadow
-
End Sub
Sign in to post your reply or Sign up for a free account.
Similar topics
by: bart plessers |
last post by:
Hello,
Somewhere in my code I have
<input TYPE="button" NAME="btnFirst" VALUE="<<" OnClick="GetFile('1')"
DISABLED>
I changed the layout of the INPUT with a stylesheet to
INPUT {
color:...
|
by: bart plessers |
last post by:
Hello,
Somewhere in my code I have
<input TYPE="button" NAME="btnFirst" VALUE="<<" OnClick="GetFile('1')"
DISABLED>
I changed the layout of the INPUT with a stylesheet to
INPUT {
color:...
|
by: JohnSouth |
last post by:
Hi I've an image submit button on a form that needs to appear flat on
the surface. I can't get rid of the shadow that appears bottom and
right.
This is the best I can do.
<code>...
|
by: jack |
last post by:
Hi.. aaa... i tried a lot btu couldnt find on net,
Im trying to get the hover effect of the web button . but dont know how
to get this ..
Please help
Thanks Awaiting for the answer..
|
by: phil-news-nospam |
last post by:
The following test/experiment page has a drop shadow in CSS that also
uses the hover selection to modify the apparent height perception the
drop shadow is doing. The problem is the top-right and...
|
by: phil-news-nospam |
last post by:
I bet this won't work in IE>
http://phil.ipal.org/usenet/ciwas/2006-05-04/more-shadow-boxes.html
Move the mouse pointer from box to box.
Comments (on other than it's silliness and absurdity)...
|
by: tomb |
last post by:
In FF 2 and Netscape 7.2 this button works exactly as desired, and that
is hovering anywhere over the button activates the hover action. But in
IE 6, only mousing over the text of the link...
|
by: msk1 |
last post by:
The code works fine in JSFIDDLE, both in Mozilla and IE, but when I paste this code in my facebook iFrames tab, I get crazy scroll down in IE/Chrome (Mozilla works fine just like in JSFIDDLE).
...
|
by: nomad |
last post by:
Hello Everyone:
I need some help on resolving a problem. Inside my sytle_buttons.css file there is an code that is blocking input fields in the contact form.
is there away to avoid using the...
|
by: ahmedsalem |
last post by:
Is it possible to implement mouse hover selection by hover on the object and drawing a circle and drag selection hover box in WPF. what I want specifically when the user hover on the button a by...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
| |