Solved

How does image works in Buttons

Posted on 2004-09-21
7
840 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now