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

Experimenting with Icon on command button

Status
Not open for further replies.

AndrewMozley

Programmer
Oct 15, 2005
621
GB
I have created an icon, using the (Free) Greenfish Icon Editor and have saved it as a 16*16 .ico file.

When I include it as a picture on a command button, it seems to come our larger than that: my command button is 36 pixels high , but the icon almost fills the height: it is about twice the linear size I wanted. If I make the command button bigger or smaller, the icon remains the same size.

Is there some scaling property which determines the size that that the icon assumes on the command button?

I notice that if I create a 24*24 bit icon and put it on the command button, it looks pretty much the same size as the 16 * 16 icon.
 
Andrew,

The thing to remember about ICO files is that one file can hold icons of many different sizes. What you are seeing is VFP choosing the wrong size for your buttons.

I vaguely remember reading somewhere that you can force VFP to always display the smallest icon in the file if you change the extension from ICO to ICON. I think I tried it once, but abandoned it, presumably because it didn't work (sorry I can't remember the details).

My own solution is not to use ICO files for command buttons, but to use BMPs instead. You can create BMPs at whatever size you like, and VFP will correctly render them in that size. What's more, any white areas in the image will be rendered as transparent, which greatly improves the appearance of the command button.

It's likely that your icon editor has an option for converting from ICO to BMP, but if not you should be able to find a free tool somewhere to do the job.

One other tip. Create a separate greyed-out version of the image for use when the button is disabled (use the DisabledPicture property for that). It will look much better than the default rendering that VFP applies. Again, your editor should have an option to grey out an image, or at least to convert it to grey scale.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Thanks Mike. You are quite correct, and also an impressive repository of VFP trivia!

I have changed the name of my icon to have a .icon extension, and the picture is displayed correctly (I believe) as a 16*16 pixel image which fits onto the command button.

That has been a great help.

Andrew.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top