Solved

How does image works in Buttons

Posted on 2004-09-21
7
851 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

832 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