Solved

Visual Basic Mouse Over Image Question

Posted on 2013-12-09
8
231 Views
Last Modified: 2013-12-22
I have twenty custom button images on a main menu.  Font color black.  Visible=True
I made twenty other identical images directly over each.  Font color yellow. Visible=False
When the mouse passes over a black font button,  I turn the visible property of the yellow button on and off when it hits the regular background.  Works great except that randomly a button blinks instead of just transitioning  smoothly from one font color to the other.  Any suggestions how to correct the occasional blinking or a better technique? Thank You
0
Comment
Question by:GarySB
  • 5
  • 3
8 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39707841
What kind of buttons are they and can you zip up and attach your project?
0
 

Author Comment

by:GarySB
ID: 39709879
Below are two Subs. The first activates when the mouse passes over a menu selection. I basically swipe out one image for the highlighted one and change it back when the user moves the mouse off of the image.  When I move the mouse over all the buttons, it goes well and then one of the images will completely blink instead of just smoothly changing to the highlighted image I am passing. It seems to happen randomly to any one of them.  I originally tried just turning the visibility value true & false, but I had the same performance result, Thanks for your assistance.

Private Sub LevelClick_cmd_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

    ' LevelClick_cmd(20) Images are black font
    ' LevelClick_cmd3(20) Images are yellow font
      
    ' If they are on the same selection then do nothing.
    If SImage = Index Then Exit Sub
   
    ' turn off previous highlighted yellow image
    If SImage > 0 Then
        ' yellow
        LevelClick_cmd(SImage).Picture = ImageTransport.Picture
    End If
   
    SImage = Index  ' set variable to current image mouse is over
           
        ' save original image to put back
        ImageTransport.Picture = LevelClick_cmd(SImage).Picture
      ' now highlight
        LevelClick_cmd(SImage).Picture = LevelClick_cmd3(SImage).Picture

End Sub

(red_img is the menu background)
Private Sub red_img_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    ' switch image back to original if user moves mouse off image.
    If SImage > 0 Then
        LevelClick_cmd(SImage).Picture = ImageTransport.Picture
        SImage = 0
    End If

End Sub
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39709898
Let me ask again - can you zip up and attach your project?
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:GarySB
ID: 39709921
The two Subs I provided are complete.
The actual project is too large, plus the extra code has nothing to do with the main menu image flickering.  Before I did not highlight the command buttons I used when the mouse past over.  I think it looks much better this way.
0
 

Author Comment

by:GarySB
ID: 39709926
One other point! I am not using a timer so no delay should be happening.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 39709957
Without the actual project I won't be able to see what happens and debug the code. Create a zip file, upload it to www.mediafire.com and post the resulting URL.
0
 

Accepted Solution

by:
GarySB earned 0 total points
ID: 39725605
I deleted the Image objects and replaced them with Picture ones and the blinking is gone. Poor characteristic of the Image performance.
0
 

Author Closing Comment

by:GarySB
ID: 39734474
The Image does not have the quality to clearly swap objects without resulting in blinking.  After many hours of trying I just substituted with Picture objects and they work great.  I could not upload my project as requested, so I had to come up with an alternative.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now