473,659 Members | 3,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

add icon to resource and use different sizes

Hi,

In my VB.NET 2005 application I want to reuse several icons in different
sizes. My icons contains images of 16x16, 24x24, 32x32 and 48x48. The
problem is: I doesn't always use the right size: sometimes it resizes the
48x48 image to 16x16 instead of taking the 16x16 image. Is there a way to
specify which image of the icon has to be used?

Thansk a lot in advance,

Pieter
Nov 21 '05 #1
4 3838
Pieter,

The icon class has several constructors that take as arguments an
existing icon, and a preferred size:

Initializes a new instance of the Icon class and attempts to find a
version of the icon that matches the requested size.
[Visual Basic] Public Sub New(Icon, Size)

Initializes a new instance of the Icon class from a resource in the
specified assembly.
[Visual Basic] Public Sub New(Type, String)

Initializes a new instance of the Icon class and attempts to find a
version of the icon that matches the requested size.
[Visual Basic] Public Sub New(Icon, Integer, Integer)

You should be able to pass it the Icon that you loaded from your
resource, plus the desired size. MSDN docs say that is uses an icon of
the closest size. If you need a 48x48 and one isn't there, then it
might use the 32x32. If you need a 48x48, you will have to use
Graphics.DrawIm age and stretch the image during drawing.

I hope this helps, please let me know how it turns out.

-- Tim

Nov 21 '05 #2
Thanks for the info. Any idea how I can do this at designtime? For instance:
I have buttons, and the image-property must be set to the icon. I would like
to set these at designtime, but there doesn't seem to be a way to add
specify there the size?

Thanks a lot anyways!

Pieter

"Tim Scott" <ti******@gmail .com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.com...
Pieter,

The icon class has several constructors that take as arguments an
existing icon, and a preferred size:

Initializes a new instance of the Icon class and attempts to find a
version of the icon that matches the requested size.
[Visual Basic] Public Sub New(Icon, Size)

Initializes a new instance of the Icon class from a resource in the
specified assembly.
[Visual Basic] Public Sub New(Type, String)

Initializes a new instance of the Icon class and attempts to find a
version of the icon that matches the requested size.
[Visual Basic] Public Sub New(Icon, Integer, Integer)

You should be able to pass it the Icon that you loaded from your
resource, plus the desired size. MSDN docs say that is uses an icon of
the closest size. If you need a 48x48 and one isn't there, then it
might use the 32x32. If you need a 48x48, you will have to use
Graphics.DrawIm age and stretch the image during drawing.

I hope this helps, please let me know how it turns out.

-- Tim

Nov 21 '05 #3
Tim
Pieter,

I have no ideas, sorry. I noticed that the PictureBox control will
always pick the right icon size (as you resize it in the designer) when
in StrechMode. But a Button control always seems to pick the largest
(or last?) image defined in the icon file.

-- Tim

Nov 21 '05 #4
Yes indeed, and this behaviour anoys me, hehe :-)

"Tim" <ti******@gmail .com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Pieter,

I have no ideas, sorry. I noticed that the PictureBox control will
always pick the right icon size (as you resize it in the designer) when
in StrechMode. But a Button control always seems to pick the largest
(or last?) image defined in the icon file.

-- Tim

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1545
by: ianruffell | last post by:
i've added an icon to an app i've written. when a shortcut is added to the desktop the icon colour is as expected. hwoever, when i run the app, both the taskbar icon and the icon on the app lose colour. if you need further details please ask. i've searched for an answer on numerous occasions but cannot find anything. your help would be greatly appreciated.
0
1376
by: Haim Ashkenazi | last post by:
Hi I'm trying to build a binary with py2exe. I've used the method suggested in the py2exe wiki about adding icon resources to apps. it build ok on win2k, but when I try to build the same on win98 I get this error: copying C:\Python23\Lib\site-packages\py2exe\run.exe -> C:\My Documents\NS_Backup\dist\NS_Backup.exe Traceback (most recent call last): File "Setup.py", line 13, in ?
2
3533
by: Joe Wong | last post by:
Hi, I have encountered an error whenever I put the "icon_resources" line in my setup.py file: from distutils.core import setup import py2exe setup(
3
5008
by: Grytpype-Thynne | last post by:
Is it possible to give a width to a floated div which is greater than the width of the image it contains? What I want to do is display some images which will be of different sizes so that they have their centers vertically aligned, I was thinking of using a fixed width container with one image floated left and one right with the images centered in their respective boxes and then the same down the page. I am using a table to obtain the...
3
2000
by: JR | last post by:
Take a look at TestStruct1 and TestStruct2. Clearly, the D2 part of the union is MUCH larger than the D1 portion. I would expect sizeof(TestStruct1)==sizeof(TestStruct2) but that is not the case using Microsoft Visual C++ 2003. Here is what I get sizeof(TestStruct1)==0x108 sizeof(TestStruct2)==0x104 Is this normal C++ compiler behavior, or a bug in the compiler?
1
2109
by: Brian Henry | last post by:
I have an icon in my app as an embeded resource.. i am accessing it through the assemblies getmainfestresourcestream method of the assembly. The icon has a 32x32 and a 16x16 icon in the same icon resource, I want to draw the 16x16 one on the screen, how would I do this? the only icon i get back when making a icon object out of it is 32x32.. but i need the smaller one, thanks!
0
2962
by: Mythran | last post by:
I wrote some code that is supposed to enumerate through the specified file's win32 resources and return a string-array of all icon names. When it runs, it returns a string-array with a bunch of numbers in sequential order (1-55 when ran against iexplore.exe). When I open up iexplore.exe in Visual Studio, I see 23 icons. Each icon has 1 or more sizes of the icon...I'm assuming that there are, in fact, 55 icon resources in iexplore.exe,...
0
936
by: Steve McKewen | last post by:
Found it. You have to use the ToBitmap method in the Icon object, then that will convert to an Image. Image^ aImage = theIcon->ToBitmap(); Steve
4
1747
TheSmileyCoder
by: TheSmileyCoder | last post by:
I need some simple 16x16 icons to use in a treeview on my form. Anyone know a good resource site for SIMPLE icons? Alot of the icons I have found are either so complex that they look like hell when scaled down, or cost something, or they only have 3 of the icons im looking for, and I would like a style that "goes" together. Im looking for icons such as: Circles in various colours, not filled, partially filled, fully filled. Checkmark (in...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8748
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.