Solved

Icon size on graphic buttons

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
Learn how to set up basic frames and paths in Prezi and understand the open space that Prezi allows you to create presentations in.
Not only does Prezi allow you to create non-linear presentations, it also makes it easy to apply transition animations between your frames. Learn how to apply a fade-in transition to select items and entire frames in this tutorial Select "Edit Path"…

816 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

11 Experts available now in Live!

Get 1:1 Help Now