Solved

Icon size on graphic buttons

Posted on 2000-02-28
4
268 Views
Last Modified: 2013-11-19
Ok... I have an application in VB5 which has several command buttons all with graphics - and no text.  The graphics are icons to get the invisible background. They are all created at 48x48 pixels. The compiled exe runs fine on about 6 different machines yet on one particular Win95 machine the application displays the icons at 32x32 pixels... ie it shrunk them down and they look terrible. They consequently only fill 75% of the button. I have tried creating icons of different colour depth (24bit, 16bit, even 256 colour). I have also tried other screen res setting (800x600, 1024x768 etc).

I have also tried machines running NT4. Some with and some without Plus Pack.

Even so... this one machine (Toshiba incidently) refuses to display my icons at the original 48x48 pixels.  Even WinZip displays icon buttons correctly at 48x48. What am I doing wrong with the VB?

0
Comment
Question by:Upland
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
Erick37 earned 100 total points
ID: 2567090
Use a 48x48 bitmap (bmp) image instead of an icon.
Set the Command button's MaskColor property to the color you want to be transparent in your bitmap, and set the UseMaskColor property True.
0
 
LVL 4

Expert Comment

by:Jeremy_D
ID: 2568316
Be sure to check the size of the buttons too. If you set them to 780 (52x15) twips, that will display correctly on most systems, but some graphics chips use another ratio (like the new intel 810 motherboard with on-board graphics chip).

The icon is in pixels, so that is a constant, but the button should be set to a size of 52 x TwipsPerPixelX width and 52 x TwipsPerPixelY height (52 in stead of 48 to accomodate for the 2 pixel width borders of the command button) programmatically to allow correct display on systems with differen twips/pixel ratios. Alternatively, you can set the form's scalemode to Pixels in stead of Twips and make the buttons a width and height of 52.

0
 

Author Comment

by:Upland
ID: 2569561
Thank you.... works a treat! I've learned something new.  

By the way, is this the way in which WinZip (for example) can display buttons which are disabled and the displayed graphic is in the windows system colours? I'll have a play.

Thanks again
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2570162
The Command Button can also have a DownPicture and DisabledPicture assigned to it.  You must create a separate bitmap for each of these images if you use them.

There is the DrawState() API call which can take one bitmap, and generate a "disabled look" bitmap from it at runtime.  This effect is used in the toolbar of VB's IDE for example.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

706 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

18 Experts available now in Live!

Get 1:1 Help Now