Solved

Icon size on graphic buttons

Posted on 2000-02-28
4
272 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need Graphic Design work done 2 80
AutoCad licenses 9 55
VBA filters 2 50
Looking for VB6 code to read SQL table export it to ascii 8 31
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
In this Micro Tutorial viewers will learn how to remove an unwanted object using Photoshop’s feature known as content-aware fill.

932 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

14 Experts available now in Live!

Get 1:1 Help Now