Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pictures and "mouse-over" event

Status
Not open for further replies.

MikeBronner

Programmer
May 9, 2001
756
US
I'm trying to create a rollover image menu and have it set up and working. However, currently the program must load the menu item picture anew each time the mouse moves over the button (I'm using the LoadPicture method).

Is there any way to load the picture into memory, and then reference them there instead of reading them each time from the drive?

Or even better, has anyone played with a roll-over image menu system before and developed a better solution? Best Regards and many Thanks!
Michael G. Bronner X-)

"Life is too Short to Drink Cheap Beer"
 
Hi,

What about creating an array of image controls, load the picues into them when your start up your project and then setting the visible property when you want to display them?

Sunaj
 
Or you could create a resource file which stores the pictures. The file is compiled into your exe.

Herman :-Q
 
Harman, thats just what I did, and it works great :)

But I also used the array inconjunction with that. Thank you both! :) Best Regards and many Thanks!
Michael G. Bronner X-)

"Life is too Short to Drink Cheap Beer"
 
I got it working perfectly with the following code:

Dim nMove As Integer
Private Sub Form_Load()
nMove = 20 'only have 10 buttons; setting it out of
'range
End Sub
Private Sub picMenuItem_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Siingle)
Dim i As Integer

If (Index <> nMove) Then
For i = 0 To 9 Step 1
picMenuItem(i).Picture = LoadResPicture(i+60,0)
Next i
picMenuItem(Index).Picture = _
LoadResPicture(Index+70,0)
nMove = Index
End If
End Sub


Now for the problem: VB doesn't have a &quot;mouse_off&quot; event... how do I reset the image when the cursor leaves it? Best Regards and many Thanks!
Michael G. Bronner X-)

&quot;Life is too Short to Drink Cheap Beer&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top