473,472 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Form Flickering with On Mouse Move event

10 New Member
The ultimate goal:
To create a mouseover effect for a control (command button) in which the text changes color. I have been dealing with flickering screens and controls and have come a long way but I am now stuck.

Originally - when the control is moused over, the control would flicker like crazy. With some adjustment to the coding I got the control to stop flickering, but now instead the entire form flickers once when the control is moused over and once when the mouse leaves the control. Code is as follows:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. If Me.TitleB.Visible <> False Then
  3. Application.Echo False
  4. Me.Title.Visible = True
  5. Me.TitleB.Visible = False
  6. Application.Echo True
  7. End If
  8. End Sub
  9.  
  10. Private Sub Title_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  11. If Me.TitleB.Visible <> True Then
  12. Application.Echo False
  13. Me.Title.Visible = True
  14. Me.TitleB.Visible = True
  15. Application.Echo True
  16. End If
  17. End Sub
Additionally, I have an image as the background for the form. If I remove all images from the form the flicker does not occur.

I have been researching for hours. Someone PUHLEASE help.
Dec 5 '19 #1

✓ answered by twinnyfo

So.........................

Minor piece of advice: Name your controls according to a common, recognizable naming convention. Find one and stick with it.

Second, here is a recommendation. If these are just rectangles (which I had no idea, because of the indiscriminate name), then we may have some options. Here is one:

Here is my assumption, but you will have to correct me as required.
  1. You have command buttons that have images on them.
  2. You have rectangles (the "rectangle object") surrounding the command buttons.
  3. The rectangles have a transparent background, but a yellow border.
  4. The rectangles, by default are invisible, but when one hovers over the command button, the rectangles become visible.
  5. When one moves away from the command button, the rectangles go invisible again.

These assumptions will drive the following:
  1. Remove all your Rectangles and replace them with Labels. Name them as follows: lblBorder1, lblBorder2, lblBorder3, etc.
  2. Make the background of the Labels transparent, with no text as their caption.
  3. You could use regular image controls for this, but for now, you can keep the Command Buttons. Just make sure the Command Buttons are underneath the labels you create.
  4. On the Labels, add the On Click event that you would have for your Command Buttons.
  5. Make the Labels visible, solid yellow border (the way you want them to appear when hovered).
  6. Then, change the border style to transparent (but don't change anything else about the border).
  7. Remove the MouseMove and OnClick events from the Command buttons
  8. In each Label's MouseMove Event, enter this: =ShowBorder(x), where x is the number of the Label
  9. In the Detail of the form, add this to the MouseMove event: =ShowBorder(0)
  10. Place this code into your form:

Expand|Select|Wrap|Line Numbers
  1. Private Function ShowBorder(Display As Integer)
  2.     Dim intX As Integer
  3.  
  4.     If Display = 0 Then
  5.         For intX = 1 To 5
  6.             If Not Me("lblBorder" & intX).BorderStyle = 0 Then _
  7.                 Me("lblBorder" & intX).BorderStyle = 0
  8.         Next intX
  9.     Else
  10.         If Not Me("lblBorder" & Display).BorderStyle = 1 Then _
  11.             Me("lblBorder" & Display).BorderStyle = 1
  12.     End If
  13. End Function
That "should" keep everything tidy, and perhaps prevent some of the flickering. The flickering "could" be your system; it "could" be that you have a form that's massively draining your system resources; it "could" be that I am just unable to reproduce the flickering.

However, try this method of feline de-dermafication, and see if it hepps!

19 3917
twinnyfo
3,653 Recognized Expert Moderator Specialist
kbrice100,

Welcome to Bytes!

I can't tell you exactly "why" Access does this, but it "appears" that when Access makes one thing visible/invisible, the system sometimes tries to repaint the entire form. I've had some experiences with similar flickering issues in the past. Some other experts might have a better idea as to why this happens.

Concerning your code, since it appears that you are only ever changing the one item (Me.TitleB.Visible), there should be no reason to turn the Echo on or Off (in fact, that may be causing some of the flickering effect).

Additionally, you can streamline your code so that you use only one procedure for the turning on/off of TitleB, but call it differently in each circumstance. See below:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_MouseMove( _
  2.     Button As Integer, _
  3.     Shift As Integer, _
  4.     X As Single, _
  5.     Y As Single)
  6.  
  7.     Call RefreshForm(DisplayTitleB:=False)
  8.  
  9. End Sub
  10.  
  11. Private Sub Title_MouseMove( _
  12.     Button As Integer, _
  13.     Shift As Integer, _
  14.     X As Single, _
  15.     Y As Single)
  16.  
  17.     Call RefreshForm(DisplayTitleB:=True)
  18.  
  19. End Sub
  20.  
  21. Private Sub RefreshForm( _
  22.     DisplayTitleB As Boolean)
  23.  
  24.     If Not Me.TitleB.Visible = DisplayTitleB Then _
  25.         Me.TitleB.Visible = DisplayTitleB
  26.  
  27. End Sub
I did test the above code and I experienced no flickering, but my form only had two items on it.....

Hope this hepps!
Dec 9 '19 #2
kbrice100
10 New Member
twinnyfo,

Thank you for your reply!

The code works to stop the entire form from trying to repaint but the flicker has moved to the control itself. I can't tell if it's "Title" or "TitleB" since they are both behind each other but this is what happens:

By default, the control is a command button set with an invisible background, so all you see is the letters. When the mouse is moved over the box-shaped control, that entire box will flicker once, TitleB will become visible as it should, and then when you move off of the control box it flickers once again and TitleB disappears as it should.

So - it works and is definitely better than the original seizure-inducing flickering, but I would really love to see no flicker at all for that complete, professional product.

I'm wondering if the default invisible background has something to do with it?
Dec 9 '19 #3
twinnyfo
3,653 Recognized Expert Moderator Specialist
Have you tried changing the hover color on the command button? Then you don't have to concern yourself with all the Mouse Move events.

That might makes things even better....
Dec 10 '19 #4
kbrice100
10 New Member
So I guess with the text yes that could be an option but I have 5 command buttons on the form that act as links to different areas in the database (the text is a link to our website) and these command buttons have pictures as their fill and my idea was as these are hovered over a yellow border shows around them

Thus the concept is the same and when the code you provided is duplicated for these controls the same issue arises - on hover, rectangle control appears and cmd button control flickers once, on mouse move out, cmd button flickers once and rectangle control disappears

And of course, MS Access doesn't have a "Hover Border Color" option which seems absolutely silly to me and I can't believe they haven't put it in after so many years

At the end of the day, I could either:
1) Deal with the slight flicker
2) Use the text hover color option for the text and have nothing for the other 5 command buttons

Unless I can get that dang flicker to go away! I've got until 1 Jan to try and figure it out lol
Dec 10 '19 #5
twinnyfo
3,653 Recognized Expert Moderator Specialist
So.........................

Minor piece of advice: Name your controls according to a common, recognizable naming convention. Find one and stick with it.

Second, here is a recommendation. If these are just rectangles (which I had no idea, because of the indiscriminate name), then we may have some options. Here is one:

Here is my assumption, but you will have to correct me as required.
  1. You have command buttons that have images on them.
  2. You have rectangles (the "rectangle object") surrounding the command buttons.
  3. The rectangles have a transparent background, but a yellow border.
  4. The rectangles, by default are invisible, but when one hovers over the command button, the rectangles become visible.
  5. When one moves away from the command button, the rectangles go invisible again.

These assumptions will drive the following:
  1. Remove all your Rectangles and replace them with Labels. Name them as follows: lblBorder1, lblBorder2, lblBorder3, etc.
  2. Make the background of the Labels transparent, with no text as their caption.
  3. You could use regular image controls for this, but for now, you can keep the Command Buttons. Just make sure the Command Buttons are underneath the labels you create.
  4. On the Labels, add the On Click event that you would have for your Command Buttons.
  5. Make the Labels visible, solid yellow border (the way you want them to appear when hovered).
  6. Then, change the border style to transparent (but don't change anything else about the border).
  7. Remove the MouseMove and OnClick events from the Command buttons
  8. In each Label's MouseMove Event, enter this: =ShowBorder(x), where x is the number of the Label
  9. In the Detail of the form, add this to the MouseMove event: =ShowBorder(0)
  10. Place this code into your form:

Expand|Select|Wrap|Line Numbers
  1. Private Function ShowBorder(Display As Integer)
  2.     Dim intX As Integer
  3.  
  4.     If Display = 0 Then
  5.         For intX = 1 To 5
  6.             If Not Me("lblBorder" & intX).BorderStyle = 0 Then _
  7.                 Me("lblBorder" & intX).BorderStyle = 0
  8.         Next intX
  9.     Else
  10.         If Not Me("lblBorder" & Display).BorderStyle = 1 Then _
  11.             Me("lblBorder" & Display).BorderStyle = 1
  12.     End If
  13. End Function
That "should" keep everything tidy, and perhaps prevent some of the flickering. The flickering "could" be your system; it "could" be that you have a form that's massively draining your system resources; it "could" be that I am just unable to reproduce the flickering.

However, try this method of feline de-dermafication, and see if it hepps!
Dec 10 '19 #6
kbrice100
10 New Member
I have learned to practice good naming conventions for the controls. I apologize when I was mentioning the rectangle control I was just referring to it that way because that is the control "type" as described in Access.

Regardless, I understand the new concept you're going with here. Unfortunately I believe I'm making a rookie mistake (I'm self-taught with VBA and have only been using it for ~6 months).

When I put =ShowBorder(x) and =ShowBorder(0) in their respective places I get a compile error:

"Expected: line number or label or state or end of statement"

Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_MouseMove(Button As Integer, _
  2.   Shift As Integer, X As Single, Y As Single)
  3.     = ShowBorder(0)   
  4. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub lblBorder1_MouseMove(Button As _
  2.  Integer, Shift As Integer, X As Single, Y As Single) _
  3.     = ShowBorder(1)
  4. End Sub
I tried putting:
Expand|Select|Wrap|Line Numbers
  1. MelblBorder1 = ShowBorder(0)
and get "Object doesn't support this property or method"

And I have a feeling I'm just not understanding that part of your instruction so I apologize and appreciate your patience!
Dec 11 '19 #7
twinnyfo
3,653 Recognized Expert Moderator Specialist
=ShowBorder(x) and =ShowBorder(0) should go in the PROPERTY for MouseMove, not in the VBA. In fact, delete the VBA for those events.
Dec 11 '19 #8
kbrice100
10 New Member
Ah! Okay

Well with the new method implemented the same, single flicker still occurs.

As you said, I'm wondering if it's just too much for the system. Which if that is the case, I will have to either deal with the flicker or maybe just do without the hovering feature as it is not necessary but just gives it a little extra "umph."
Dec 11 '19 #9
twinnyfo
3,653 Recognized Expert Moderator Specialist
I get the "Umph" factor. It is one of the ways you can make your applications look more professional.

Keep striving for excellence! It takes a lifetime of working with Access to know all of its intricacies.
Dec 11 '19 #10
kbrice100
10 New Member
It has to do with the background image being too large for Access to handle well because when that is removed everything works just fine. I've researched things like double buffering (doesn't seem to be possible with Access) and handling images different ways but it just seems to be a limitation of Access, which is very unfortunate. Not using the image as my form's background is not an option, so I will have to deal with less "effects".
Dec 11 '19 #11
twinnyfo
3,653 Recognized Expert Moderator Specialist
You can try to reduce the size of the image. That might hepp!
Dec 11 '19 #12
kbrice100
10 New Member
Yes but with it being set as the background image it becomes quite "fuzzy" very quickly since it has to be stretched to fit the entire screen and the reduction required to stop any flickering makes it unsatisfactory.

The Application.Echo property is able to get the controls themselves to stop flickering which makes me think there is a possible solution in there somewhere. But it also causes the entire form to flicker non-stop at an interval. So it fixes one issue and creates another.

I've conducted hours of fruitless research and I believe I have passed the point of it being worth it. If I want to keep an image as the background of the form, I'll have to accept that the effects on that form are going to be limited.
Dec 11 '19 #13
twinnyfo
3,653 Recognized Expert Moderator Specialist
Hmmmmmmmmmmmmmm........................

Would you mind sending the image file? And what are the dimensions of the form you want for the image?

I might could play with it for a bit.....
Dec 11 '19 #14
kbrice100
10 New Member
Another rookie question - how do I do that? haha
Dec 12 '19 #15
twinnyfo
3,653 Recognized Expert Moderator Specialist
When you type your reply, click the advanced button. This will give you options for uploading attachments. Please attach the image and not a link to a hosted image.

Thanks!
Dec 12 '19 #16
NeoPa
32,556 Recognized Expert Moderator MVP
Nice work (as always) Twinny.

Nice to see K Brice also continuing to explore and progress.

Interesting thread :-)
Dec 14 '19 #17
kbrice100
10 New Member
Okay images are attached I believe.

BG1 is the main form background picture. The other four pictures are four out of the five pictures I have as the clickable "pictures" to take users to their respective sites - I figured I'd add those in there to give you a more complete picture (no pun intended) of what I'm working with.

Also most monitors users will have display a resolution of 1680 x 1050, and that would be the biggest.

Please let me know if you have any questions.
Attached Images
File Type: jpg BG1.jpg (157.7 KB, 106 views)
File Type: jpg B-BETC.jpg (31.4 KB, 96 views)
File Type: jpg B-PATS.jpg (26.8 KB, 76 views)
File Type: jpg B-SNAFU.jpg (28.0 KB, 90 views)
File Type: jpg B-USTAR.jpg (26.2 KB, 95 views)
Dec 16 '19 #18
twinnyfo
3,653 Recognized Expert Moderator Specialist
This may be one of those cases in which your bells and whistles merely make a lot of noise but provide no value added. This is not meant in a mean way....

Are your pictures (for the last four images) embedded in the background and you've created clickable controls over the image of the button? At least this is what it seems you have described.

If those are just forms, It is certainly much easier to simply build the form with command buttons. Even though command buttons don't have a "HoverBorderColor" as a property, there are ample enough hover properties to make it clear that a user is hovering their mouse over a command button--all of which is built into MS Access and you never have to worry about building additional procedures. Of course, these were added to provide additional flexibility--I'm just not sure your design warrants such complexity to simply allow users to navigate to different forms.

Please take all this advice with a grain of salt sprinkled with some sugar..... We are glad to help you design your DB however you want and to the best of our abilities. But, we also try to offer realistic advice when warranted. This is just one of those cases.

Trust me: I LOVE bells and whistles in my projects, and I think when added to a form they can be both useful and productive. However, in your case, simplicity is not necessarily a bad thing.

Also, aside from your first image, all resolutions came out as 289x244, so there's not much I could do with those pictures, anyway. you may have to zip them and upload.

I'm glad to keep working on this with you.
Dec 16 '19 #19
kbrice100
10 New Member
I concur, which is why I was beginning to feel the time spent in trying to figure it out was past being worth it.

No offense taken! I appreciate all of your advice and input. I think for now I'm going to let it go and rest easy with the simpler approach.
Dec 16 '19 #20

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

Similar topics

0
by: William Bub | last post by:
I am using VB 6.0 Working Model (the one with no help files). I have a form. On a portion of the form I have a Picture Box. On the PicBox I want to draw something to follow the mouse. I can detect...
4
by: Eduard Witteveen | last post by:
Hello, I want to make a hooverbox, which is shown when the mousepointer is not moved for a amount of time. When the hooverbox is shown, i will do a server request to retrieve the information...
2
by: Roger | last post by:
I'm trying to build a controls editor, that given a control (textbox) somewhere on a form, it can be moved using the mouse to drag-drop I have a simple form with a square text box (1" x 1") and...
3
by: Logan Mckinley | last post by:
I need to be able to detect mouse movement even when it is not over my application. I can get the mouse cords using MousePosition but I am not sure if there is an event that hits my program when...
1
by: Jax | last post by:
I want my application to stop a certain action when it hasn't felt a mouse move for over 10 minutes I understand I could do this by using the mousemove event of the form of my application But if my...
0
by: Muhammad Aftab Alam | last post by:
Hi All, I am facing a problem during changing the cursor on the mouse move event of a List View control. the event is captured but when I try to change the cursor as with the following code...
1
by: Marc Noon | last post by:
I'm fighting a problem with mouse move event and need serious help. I have a form, when it is not visibile I want it to recognize when the mouse is on the far right side of the desktop screen or...
2
by: luanhoxung | last post by:
hi ! i try to use fSetFontBold("labelname") on Mouse move event but it dont do. Pls help me. Thanks with appreciatedly. Luan
0
by: kirann | last post by:
hi , i have an application on windows which requires me to contant move mouse or hit keyboard inorder not to go that app in to idle mode. How can i use keyboard events or mouse move events to...
3
by: pfm721 | last post by:
I know the control tip text will display information about a text box. However I was wondering if there is a way to change it based on the value of the text box. Is it possible to create a mouse...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
1
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...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.