How to set image for button hover (1 Viewer)

TxStrob

Registered User.
Local time
Today, 10:59
Joined
Sep 23, 2019
Messages
44
I would to set a foreground image, for when the mouse hover the button it displays the alternate color image. How do you do this?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 01:59
Joined
May 7, 2009
Messages
19,231
add three Image control to your form (Image1, Image2, Image3).
Image1 and Image two are same image.
Image3 is different image.
set both Image2 and Image3, Visible property to No.
add code to details section mousemove event and to image1 mousemove event:
Code:
Option Compare Database
Option Explicit

Dim strImageName As String

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If strImageName <> "Image1" Then
        strImageName = "Image1"
        Me.Image1.PictureData = Me.Image2.PictureData
        Me.Repaint
    End If
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If strImageName = "Image1" Then
        strImageName = ""
        Me.Image1.PictureData = Me.Image3.PictureData
        Me.Repaint
    End If
End Sub
 

TxStrob

Registered User.
Local time
Today, 10:59
Joined
Sep 23, 2019
Messages
44
Thank you, but it doesnt work. When I put my mouse over the image, it just goes blank.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:59
Joined
Oct 29, 2018
Messages
21,451
Thank you, but it doesnt work. When I put my mouse over the image, it just goes blank.
Hi. You might consider posting a copy of your db, so we can see how you tried to implement Arnel's suggestion.
 

TxStrob

Registered User.
Local time
Today, 10:59
Joined
Sep 23, 2019
Messages
44
My code goes from starts with private sub, then go through

Starts here If Me.cmdOpen.Visible = True Then
Then goes here Me.cmdOpen.Visible = False
Then here Me.openGreenBtn.Visible = True
and skips.... this Else Me.cmdOpen.Visible = True


Why is that?

Private Sub cmdOpen_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.cmdOpen.Visible = True Then
Me.cmdOpen.Visible = False
Me.openGreenBtn.Visible = True
Else
Me.cmdOpen.Visible = True
End If
End Sub
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:59
Joined
Oct 29, 2018
Messages
21,451
My code goes from starts with private sub, then go through

Starts here If Me.cmdOpen.Visible = True Then
Then goes here Me.cmdOpen.Visible = False
Then here Me.openGreenBtn.Visible = True
and skips.... this Else Me.cmdOpen.Visible = True


Why is that?

Private Sub cmdOpen_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Me.cmdOpen.Visible = True Then
Me.cmdOpen.Visible = False
Me.openGreenBtn.Visible = True
Else
Me.cmdOpen.Visible = True
End If
End Sub
Were you getting any error messages?
 

TxStrob

Registered User.
Local time
Today, 10:59
Joined
Sep 23, 2019
Messages
44
Were you getting any error messages?

I am receiving no error, it just skipping that area. When the mouse is over the cmdOpen, it displays openGreenBtn. It does not switch back to cmdOpen, when moving the mouse off the button.
 

isladogs

MVP / VIP
Local time
Today, 18:59
Joined
Jan 14, 2017
Messages
18,209
It won't. Once the mouse is no longer over the button that code doesn't apply.
Try putting code in the Detail_MouseMove event to make the button visible again
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:59
Joined
Oct 29, 2018
Messages
21,451
I am receiving no error, it just skipping that area. When the mouse is over the cmdOpen, it displays openGreenBtn. It does not switch back to cmdOpen, when moving the mouse off the button.

Hi. Colin is correct, and I see Arnel also gave you the code for the Detail section. Did you forget to use it?
 

TxStrob

Registered User.
Local time
Today, 10:59
Joined
Sep 23, 2019
Messages
44
Its kind of working now, is there anyway to stop the flicking when the mouse is not over button?
 

isladogs

MVP / VIP
Local time
Today, 18:59
Joined
Jan 14, 2017
Messages
18,209
In the Detail_MouseMove event, try

Code:
If Me.cmdOpen.Visible=False Then Me.cmdOpen.Visible=True
 

Users who are viewing this thread

Top Bottom