Alternating Images On Mouseover (1 Viewer)

robbydogg

Registered User.
Local time
Today, 01:11
Joined
Jul 15, 2008
Messages
56
Hello,

Not sure if this has been covered or not, but i've been trying to get a form, with some buttons on it.
What i want is to have the button show a graphic, but when the mouse is over the graphic, it change to a different one and also become active so that it can runa command when clicked.
I tried having the 1st image on top of the command image, then on mousemove i've changed the visable property to false, but it doesn;t seem to work.

Private Sub Image327_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Image327.Visible False
End Sub

Am i missing a trick somewhere or is it not possible?

Thanks.
Rob
:)
 

DCrake

Remembered
Local time
Today, 01:11
Joined
Jun 8, 2005
Messages
8,632
Guessing, If you have a command button on a form that when clicked causes the visible property of an imagecontrol to change from invisible to visible you need to do

If Me.ImageControlA.Visible = False Then
Me.ImagecontrolA.visible = True
End If

Then when the user hovers over ImageControlA it becomes invisible and ImageControlB becomes visible.

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

Me.ImageControlB.Visible = True
Me.ImageControlA.Visble = False

End Sub

*Don't know if you can make it invisible whislt it has the focus?

Then have a sub routine on ImageControlB that is run on the OnClick Envent.

Aircode untested

David
 
Last edited:

robbydogg

Registered User.
Local time
Today, 01:11
Joined
Jul 15, 2008
Messages
56
hi, thanks for the suggesiton. i tried but it seems to come up with the debug fault.

I'm not quite sure i've done it correctly to be honest.

from my understanding, the code

[If Me.ImageControlA.Visible = False Then
Me.ImagecontrolA.visible = True
End If ]

shoud be attached to a command button on it's 'mouseover' control.

then

[Private Sub ImageControlA_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Me.ImageControlB.Visible = True
Me.ImageControlA.Visble = False

End Sub ]

should be on the mouseover control on ImageControlA

then

have a routine for the command button on 'OnClick'

Is this correct?

Thanks
 

DCrake

Remembered
Local time
Today, 01:11
Joined
Jun 8, 2005
Messages
8,632
No the command should be on the button click event


Sub CmdButton_Click()
If Me.Image4.Visible = True Then
Me.Image3.Visible = True
Me.Image4.Visible = False
Else
Me.Image3.Visible = True
End If
End Sub

Then on the mouse move of the primary image (Image 3)


Me.Image4.Visible = True
Me.Image3.Visible = False

Then on the on click of the secondary image (image 4) place your code
 

robbydogg

Registered User.
Local time
Today, 01:11
Joined
Jul 15, 2008
Messages
56
AHAAAA - sussed it. (and quite chuffed with it too!!!!)
one easy way is to have each image hidden as default, with the startup image showing.

so VNF (front image showing at startup) is visable, VNB (the alternate image) is not visable. VNF on Mousemove has the following code:

Me.VNB.Visible = False
Me.VHB.Visible = False
Me.SVB.Visible = False
Me.PRB.Visible = False
Me.FRB.Visible = False


where VNB, VHB, SVB, PRB, FRB are the images that i want to become 'live' when moused over.

I've (hopefully) attached a demo file to show how it works. feeling pretty chuffed now. thanks for your help and it pushed me towards my goal!.
 

robbydogg

Registered User.
Local time
Today, 01:11
Joined
Jul 15, 2008
Messages
56
and as per usual my first attempt at attaching the file didn't work :D

here's another go.
 

Attachments

  • db1.zip
    185 KB · Views: 514

vicsar

https://about.me/vicsar
Local time
Yesterday, 18:11
Joined
Jul 25, 2012
Messages
35
This is my approach:

1. Insert a picture
2. Program the MouseMove event of the picture to show a different picture like so:

Code:
Private Sub imgReport_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.imgReport.Picture = "report-go"
End Sub

3. Program the MouseMove event of the form to show the original picture like so:


Code:
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.imgReport.Picture = "report"
End Sub

The only problem I cannot work around is the flickering... :banghead:
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 08:11
Joined
May 7, 2009
Messages
19,231
to minimize flicker only set the pic once and not on every move of the mouse:

Code:
Private Sub imgReport_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   if me.imgReport.picture<> "report-go" then _
    Me.imgReport.Picture = "report-go"
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    if me.imgReport.picture<>"report" then _
    Me.imgReport.Picture = "report"
End Sub
 

vicsar

https://about.me/vicsar
Local time
Yesterday, 18:11
Joined
Jul 25, 2012
Messages
35
to minimize flicker only set the pic once and not on every move of the mouse:

Code:
Private Sub imgReport_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   if me.imgReport.picture<> "report-go" then _
    Me.imgReport.Picture = "report-go"
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    if me.imgReport.picture<>"report" then _
    Me.imgReport.Picture = "report"
End Sub

Umm. I see what you did there, clever. Nice, yes that should lower flickering. Thanks for the idea.
 

Users who are viewing this thread

Top Bottom