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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mouse Event Inquires

Status
Not open for further replies.

janicefoo

Programmer
Apr 17, 2003
53
0
0
MY
Dear gurus and members,
I am new in VB. I have created some images to be used as buttons in VB. I have 4 buttons on a form. These buttons are RESET, RECORD, PLAY and STOP. Each button has 3 events/images (in jpg): mouseOver, mouseClick and default.
When the application is loaded, only RECORD button is enabled (with mouse over feature). When the button is clicked, RESET, STOP button is enabled. Both RESET and STOP buttons have mouseover events as well. When STOP button is clicked, PLAY (and RESET) button is enabled with mouseover event while RECORD button is disabled. If RESET button is clicked, RECORD button is enabled again.
I tried inserting the images using LoadPicture but this method requires the user to have those images stored on their pc as well, when they install and run my application. I wonder whether can I embed these images onto the form. I would like some sample codes on creating mouse over and onClick event. Any sample codes and suggestions are highly appreciated. Hope my description isn't confusing. Look forward to some prompt reply soon and have a pleasant day.

Thanks in advance,
Janice
 
for the mouse over effect: thread222-416091

I had the same problem once...

I just made 3 additional (invisible) PictureBoxes (in a control array) then changed them with...

Picture1(0).Picture = Picture1(1).Picture 'Standard
Picture1(0).Picture = Picture1(2).Picture 'Rollover
Picture1(0).Picture = Picture1(3).Picture 'Clicked

this way if you load the pictures into the pictureboxes before you compile, they are stored in the EXE...

Hope this helps...


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Load the images into an imagelist (one of the components of the Windows Common Controls) or a resource file (you'll probably want to add the resource file editor add-in via the add-ins menu).

Using the imagelist is just a slightly neater way of doing what CubeE101 is suggesting

The resource file technique is the non-COM way to do this, and has the nice feature that you can name each resource as you wish, meaning - if we follow CubeE101's example - that we can do something like:

Set Picture1 = LoadResPicture("standard", vbResBitmap)
Set Picture1 = LoadResPicture("rollover", vbResBitmap)
Set Picture1 = LoadResPicture("clicked", vbResBitmap)


 
The imagelist may be a better way to go...

I can't remember why, but when I was working with that, I had some issue with the image list...
(Too be honest, I really can't remeber what it was... I think it had to do with the Mask or something...)

Anyways, I thought about posting that, but I new the duplicate picture box method worked perfectly for me...

If the Image list works for you... I would use it instead... It is a cleaner/neater method...

Haven't tried the Resorce Method (in vb anyway... that's about your only choice in VC++ ;-))

Try the 2 methods strongm posted first, then you can always fall back on the duplicate picture boxes for a last resort...

(maybe I was still working on the pictures, and never finished it off by throwing them into an image list... you never know;-))


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Dear all,
Thank you for your prompt reply. I will take a look and try them out soon. Have a pleasant day.

Thanks
Janice
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top