Conditionally load picture woes

I

Incidental

Hi there

I have run across a problem that has me stumped and I have spent the
last few days tinkering about trying to find out how get it to work
but to no avail so I have been trudging around the news groups trying
to find an answer and again I have come up empty handed and I am
starting to feel like this idea has a grudge against me.

Anywho my problem is thus I am trying to emulate the a mouse over
effect that can been seen in MS Media Player 11 when the mouse is
moved over an area a button appears and when you click the area
changes colour to show that button is the current selection, this is
easy enough to achieve but my problem is that when you move the mouse
over that selected button it will highlight the button to show a mouse
over effect.

Does anyone know anyway to conditionally load an image into an image
control? i.e

Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As
Integer, ByVal X As Single, ByVal Y As Single)
If Image1. picture = mypicture1.bmp then 'this bit seems to be the one
giving me the problems I can't figure out how to determine which .bmp
file is actually loaded.
Image1.picture = loadpicture("c:\somefolder\somepicture.bmp")
Else
Image1.picture = loadpicture("c:\somefolder\someotherpicture.bmp")
End if
End sub

Any help would be very gratefully appreciated as this is starting to
become my nemesis as I'm sure it will turn out to be something simple
that I just haven't thought of.

Thanks

S
 
B

Bernie Deitrick

I think you need to store the image name to be able to work with it: I'm not sure of the logic you
want to use for changing the picture, but.... Also, you may need additional control to prevent
refiring and quick changes of the picture.

Dim myImage As String

Private Sub Image1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

If myImage = "" Then
Image1.Picture = LoadPicture("c:\somefolder\somepicture.bmp")
myImage = "c:\somefolder\somepicture.bmp"
Exit Sub
End If

If myImage = "c:\somefolder\somepicture.bmp" Then
Image1.Picture = LoadPicture("c:\somefolder\someotherpicture.bmp")
myImage = "c:\somefolder\someotherpicture.bmp"
Else
Image1.Picture = LoadPicture("c:\somefolder\somepicture.bmp")
myImage = "c:\somefolder\somepicture.bmp"
End If
End Sub

HTH,
Bernie
MS Excel MVP
 
I

Incidental

Hi Bernie

Thanks for the help it's much appreicated, i have been pulling my hair
out with this one... will give your code a run through as soon as i
get a chance thanks again

Steven
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top