neonlights
asked on
How does image works in Buttons
Hi everyone: I have few questions about the button image.
1) Let's say if I placed a image for a button, should I have to include this image into the installation directory - I would prefer to insert a image in the button without placing this image into my installtion package...can I do that?
2) How do I do mouse over a button and change the image of that button?
Thanks all, if I am not clear with my question, please ask me......
1) Let's say if I placed a image for a button, should I have to include this image into the installation directory - I would prefer to insert a image in the button without placing this image into my installtion package...can I do that?
2) How do I do mouse over a button and change the image of that button?
Thanks all, if I am not clear with my question, please ask me......
1) You do not need to include the picture files separately, just add them to an ImageList control on the form. They will then be included in the .exe you build. At design time the images are then stored in the forms 'frx' file
The following code will change the image every time the button is clicked by cycling through the images in the image list. The best type of images to use a re icons as they have a transparent background.
Add a button with its style property set to Graphic.
Add an ImageList and add a few icons to the image list.
Run the project and every time you click the button the image will change.
If you want to change the icon when the mouse is hovering over the button then you'd be better off using a 'toolbar' control as this functionality is built in to it.
JR
Private Sub Command1_Click()
Static i As Long
With Command1
i = (i + 1) Mod ImageList1.ListImages.Coun t
.Picture = ImageList1.ListImages.Item (i + 1).Picture
End With
End Sub
The following code will change the image every time the button is clicked by cycling through the images in the image list. The best type of images to use a re icons as they have a transparent background.
Add a button with its style property set to Graphic.
Add an ImageList and add a few icons to the image list.
Run the project and every time you click the button the image will change.
If you want to change the icon when the mouse is hovering over the button then you'd be better off using a 'toolbar' control as this functionality is built in to it.
JR
Private Sub Command1_Click()
Static i As Long
With Command1
i = (i + 1) Mod ImageList1.ListImages.Coun
.Picture = ImageList1.ListImages.Item
End With
End Sub
ASKER
Thanks JR_2003 for your advice.
questions for you:
1) let's say I have 2 different forms, and they both have different images....should I have to include imagelist on both forms?
2) what do you mean by: "The best type of images to use a re icons as they have a transparent background" - I am using macromedia - fireworks - can use this program to create it?
3) and where is the tool bar?
"If you want to change the icon when the mouse is hovering over the button then you'd be better off using a 'toolbar' control as this functionality is built in to it."
Thanks again.
questions for you:
1) let's say I have 2 different forms, and they both have different images....should I have to include imagelist on both forms?
2) what do you mean by: "The best type of images to use a re icons as they have a transparent background" - I am using macromedia - fireworks - can use this program to create it?
3) and where is the tool bar?
"If you want to change the icon when the mouse is hovering over the button then you'd be better off using a 'toolbar' control as this functionality is built in to it."
Thanks again.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Can I use those ico... are they copy rights? and any help with free icon creators?
Thank you very much
Thank you very much
You can use those icons, there is no copyright on them.
Do you have Visual C++? If so i would recomend using that.
http://www.iconarchive.com/ has plenty of icons.
Do you have Visual C++? If so i would recomend using that.
http://www.iconarchive.com/ has plenty of icons.
ASKER
Thank you so much for your help JR2003, the site you gave me was so good. I am using it...I hope no one is going come after me.....
Thanks
Thanks
Unless you pack the image along with the installation package , it cannot be accomplished.
2) How do I do mouse over a button and change the image of that button?
There will be an event listed like onmouse over or onmouse move up for the button toool. Place the code in that methd to change the image. like , cmdButton.imageURL="the path of the image"