Solved

How does image works in Buttons

Posted on 2004-09-21
7
858 Views
Last Modified: 2013-12-26
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......

0
Comment
Question by:neonlights
  • 3
  • 3
7 Comments
 
LVL 4

Expert Comment

by:Kaarthick
ID: 12112876
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?

                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"
0
 
LVL 18

Expert Comment

by:JR2003
ID: 12113198
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.Count
        .Picture = ImageList1.ListImages.Item(i + 1).Picture
    End With

End Sub
0
 

Author Comment

by:neonlights
ID: 12113249
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.

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 18

Accepted Solution

by:
JR2003 earned 500 total points
ID: 12114530
1) you can refer to the images in one form from another form so there is no need to have the image list on both forms. In my projects I often have a form called frmResources that just stoores image lists etc that are used by many forms within the project. This means that you only have to change your images for the project in one place.
To reference the control in another form just prefix the control name with the form name, e.g.:
frmResources.ImageList1.ListImages.Item(i + 1).Picture


2) There are a selection of icons included with VB, you can find these in the "Program files\common\graphics" directory, they are the ones with the '.ico' file extension.
You can use the C++ IDE to edit the icons or download a free icon editor from the internet. I'm not sure if you can use macromedia - fireworks to create them.

3) The toolbar control is in 'Microsoft Windows Common Controls 6.0' which can be selected using ctrl+T in the IDE.
Which version of VB do you have?

0
 

Author Comment

by:neonlights
ID: 12116769
Can I use those ico... are they copy rights? and any help with free icon creators?

Thank you very much

0
 
LVL 18

Expert Comment

by:JR2003
ID: 12117557
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.
0
 

Author Comment

by:neonlights
ID: 12120654
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
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question