Link to home
Start Free TrialLog in
Avatar of GarySB
GarySB

asked on

Visual Basic Mouse Over Image Question

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
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

What kind of buttons are they and can you zip up and attach your project?
Avatar of GarySB
GarySB

ASKER

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
Let me ask again - can you zip up and attach your project?
Avatar of GarySB

ASKER

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.
Avatar of GarySB

ASKER

One other point! I am not using a timer so no delay should be happening.
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.
ASKER CERTIFIED SOLUTION
Avatar of GarySB
GarySB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GarySB

ASKER

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.