473,841 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Button hover shadow

5 New Member
I have button
I want to add shadow only when hover
How I do it?
Mar 12 '23 #1
5 6918
NeoPa
32,584 Recognized Expert Moderator MVP
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 :
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Const conCB As String = "cmdTest"
  5.  
  6. Private Sub Form_MouseMove(Button As Integer, Shift As Integer _
  7.                          , X As Single, Y As Single)
  8.     Dim lngFS As Long
  9.  
  10.     With Me
  11.         With .Controls(conCB)
  12.             If X < .Left Or X > .Left + .Width _
  13.             Or Y < .Top Or Y > .Top + .Height Then
  14.                 lngFS = 11
  15.             Else
  16.                 lngFS = 15
  17.             End If
  18.             If .FontSize <> lngFS Then .FontSize = lngFS
  19.         End With
  20.     End With
  21. 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.

Attached Images
File Type: jpg Bytes.Jpg (34.5 KB, 563 views)
Mar 12 '23 #2
NeoPa
32,584 Recognized Expert Moderator MVP
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.S hadow 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.
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Const conCB As String = "cmdTest"
  5.  
  6. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer _
  7.                            , X As Single, Y As Single)
  8.     With Me.Controls(conCB)
  9.         If .Shadow <> 0 Then .Shadow = 0
  10.     End With
  11. End Sub
  12.  
  13. Private Sub cmdTest_MouseMove(Button As Integer, Shift As Integer _
  14.                             , X As Single, Y As Single)
  15.     With Me.Controls(conCB)
  16.         If .Shadow <> 1 Then .Shadow = 1
  17.     End With
  18. 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.
Mar 12 '23 #3
isladogs
462 Recognized Expert Moderator Contributor
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 CommandButtonNa me.Properties(" Shadow") or just CommandButtonNa me.Shadow

So for example, if you have a button called Command0, you can use code like this on the button's mouse move event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.     Me.Command0.BorderColor = vbRed 'add a red border
  3.     Me.Command0.Properties("Shadow") = 1 'add a drop shadow at bottom right (or try 18 or 22)
  4. End Sub
  5.  
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_MouseMov e event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.     Me.Command0.BorderColor = RGB(132, 161, 198) 'restore blue border
  3.     Me.Command0.Properties("Shadow") = 0 'remove shadow
  4. End Sub
  5.  
I have attached a simple example demonstrating the use of the above code.

Also, see the Microsoft Help article: CommandButton.S hadow property
Attached Files
File Type: zip ButtonHover.zip (19.7 KB, 76 views)
Mar 12 '23 #4
NeoPa
32,584 Recognized Expert Moderator MVP
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.
Mar 13 '23 #5
isladogs
462 Recognized Expert Moderator Contributor
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.  
  3.     'check current state of control so it only changes once
  4.     If Not Me.Command0.BorderColor = vbRed Then Me.Command0.BorderColor = vbRed 'add a red border
  5.  
  6.     If Not Me.Command0.Shadow = 1 Then Me.Command0.Shadow = 1 'add a drop shadow at bottom right (or try 18 / 22 etc)
  7. End Sub
  8.  
  9. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  10.  
  11.    'check current state of control so it only changes once
  12.     If Not Me.Command0.BorderColor = RGB(132, 161, 198) Then Me.Command0.BorderColor = RGB(132, 161, 198) 'restore blue border
  13.  
  14.     If Not Me.Command0.Shadow = 0 Then Me.Command0.Shadow = 0 'remove shadow
  15. End Sub
Mar 13 '23 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

5
28578
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: #FFFFFF;
0
6653
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: #FFFFFF;
5
35748
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> ..SearchButton { width=100;
3
4634
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..
0
1309
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 bottom-left corners have a few spots which the pointer is there, causes the effect to oscillate. Because the shadow effect is moving a relative position, when the pointer is in a position that would hover, but hover causes the position to change...
4
1382
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) ? -- -----------------------------------------------------------------------------
4
2952
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 activates the hover. Can you see what I'm missing? It's making me crazy!! TIA Tom The html:
1
1989
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). Can you help me to fix it, please? iFrames in facebook is just an app that let you paste any content (HTML,CSS,Java) that will be surrounded by facebook frame. Look at the screenshots below: http://i.imgur.com/vn8PCP5.jpg
0
1543
nomad
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 .ac-container input{ display: none; } and still have the site work right.
0
1508
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 drawing a circle this button make specific action like as click on it. Could you give a bit of sample code or a link?
0
9709
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10934
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10609
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9446
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7853
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7025
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4085
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.