Hi,
I need to know how to extract a specific icon (32x32 for instance) from an
icon file that contains more than one icon size?
Any help would be highly appreciated,
Cheers.
Mehdi 4 8556
Well, thanks. Would you please tell me how to do the same thing using the
resource files? I mean what if I store my icon in the resource file?
Thank you for your time,
Mehdi
"Hiroaki SHIBUKI [MVP]" <jp****@microsoft.com> wrote in message
news:#P**************@tk2msftngp13.phx.gbl... Hi,
I need to know how to extract a specific icon (32x32 for instance) from
an icon file that contains more than one icon size?
Any help would be highly appreciated,
Try this ;-)
Icon icon1 = IconFactory (@"C:\hoge.ico", 32, 32);
-- Hiroaki SHIBUKI [MVP]
--IconFactory.cs: BEGIN-- using System;
namespace hidori.Drawing { using System.Runtime.InteropServices; using System.Drawing;
public class IconFactory { internal enum IMAGE_TYPE : uint { IMAGE_BITMAP = 0, IMAGE_ICON = 1, IMAGE_CURSOR = 2, IMAGE_ENHMETAFILE = 3, }
internal enum LR_FLAGS : uint { LR_DEFAULTCOLOR = 0x0000, LR_MONOCHROME = 0x0001, LR_COLOR = 0x0002, LR_COPYRETURNORG = 0x0004, LR_COPYDELETEORG = 0x0008, LR_LOADFROMFILE = 0x0010, LR_LOADTRANSPARENT = 0x0020, LR_DEFAULTSIZE = 0x0040, LR_VGACOLOR = 0x0080, LR_LOADMAP3DCOLORS = 0x1000, LR_CREATEDIBSECTION = 0x2000, LR_COPYFROMRESOURCE = 0x4000, LR_SHARED = 0x8000, }
[DllImport("user32.dll")] internal static extern System.IntPtr LoadImage ( System.IntPtr hinst, string lpszName, IMAGE_TYPE uType, int cxDesired, int cyDesired, LR_FLAGS fuLoad );
public static Icon FromFile(string sFileName) { System.IntPtr hIcon = LoadImage (System.IntPtr.Zero, sFileName, IMAGE_TYPE.IMAGE_ICON, 0, 0, LR_FLAGS.LR_LOADFROMFILE|LR_FLAGS.LR_DEFAULTSIZE); return Icon.FromHandle (hIcon); }
public static Icon FromFile(string sFileName, int width, int height) { System.IntPtr hIcon = LoadImage (System.IntPtr.Zero, sFileName, IMAGE_TYPE.IMAGE_ICON, width, height, LR_FLAGS.LR_LOADFROMFILE); return Icon.FromHandle (hIcon); }
public static Icon FromFile(string sFileName, Size size) { return FromFile (sFileName, size.Width, size.Height); } } } --IconFactory.cs: END--
Hi, Well, thanks. Would you please tell me how to do the same thing using the resource files? I mean what if I store my icon in the resource file?
Does resource files means manifest resource?
Hum.. can Compact Framwork project can includes manifest resource?
--
Hiroaki SHIBUKI
"Mehdi Mousavi" <me***********@msn.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl... Well, thanks. Would you please tell me how to do the same thing using the resource files? I mean what if I store my icon in the resource file?
Thank you for your time, Mehdi
What's the manifest resource? I meant the ".resx" files. Sorry for being
this dumb, but I'm not a C# (nor a .NET) programmer.
"Hiroaki SHIBUKI" <jp****@microsoft.com> wrote in message
news:ew**************@TK2MSFTNGP11.phx.gbl... Hi,
Well, thanks. Would you please tell me how to do the same thing using
the resource files? I mean what if I store my icon in the resource file?
Does resource files means manifest resource? Hum.. can Compact Framwork project can includes manifest resource?
-- Hiroaki SHIBUKI
"Mehdi Mousavi" <me***********@msn.com> wrote in message news:%2******************@TK2MSFTNGP12.phx.gbl... Well, thanks. Would you please tell me how to do the same thing using
the resource files? I mean what if I store my icon in the resource file?
Thank you for your time, Mehdi
Hi, What's the manifest resource?
Sorry, I used "manifest resource" to mean the .NET resource in main seemlby.
I meant the ".resx" files. Sorry for being
".resx" can contains only string data. and ".resx" is .NET resource, is not
legacy Win32 resource.
In Compact Framework project, I guess (sorry, I had never check it up) that
the legacy Win32 resources (.ico , .bmp, and so on) are put on there
(=application folder) *as is*.
--
Hiroaki SHIBUKI
"Mehdi Mousavi" <me***********@msn.com> wrote in message
news:u0**************@TK2MSFTNGP12.phx.gbl... What's the manifest resource? I meant the ".resx" files. Sorry for being this dumb, but I'm not a C# (nor a .NET) programmer. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Adrian |
last post by:
How do I put an icon on a form using code?
Thank you.
|
by: Mohammad-Reza |
last post by:
Hi
I want to extract icon of an exe file and want to know how.
I look at the MSDN and find out that I can use ExtractIconEx() Windows API
but in there are some changes to that api in c# I made...
|
by: Dave |
last post by:
Can anyone tell me how to extract the resources, specifically the description
and icons, from a .EXE file programatically. Basically I want to write a C#
application that takes .EXE files and...
|
by: VP Borza |
last post by:
can anyone show me how can I extract icons from a dll or exe in visual basic
..net?
|
by: Udi |
last post by:
Hi,
I have an imagelist initialized in design time with
several icons files (.ico).
However, when I need to extract an icon (Image)
from the Imagelist, I can't convert it back to an icon:
...
|
by: Frank |
last post by:
If I have an icon file that contains one icon ExtractIconEx tells me there
is one there.
If the file contains 1 32x32 icon and one 16x16 icon ExtractIconEx still
tells me there is one.
I need...
|
by: suis |
last post by:
Hi Everybody,
I have a big dought about, how to read meta data information in a specific file type like .MSG , anyway thanks to this URL bellow . Edanmo has done a great job for that. ...
|
by: =?Utf-8?B?QmVu?= |
last post by:
Hi
I am looking for a way to extraxt an icon from a .exe file an save it as an
icon not a bitmap or jpeg to a file?
The code below extracts the icon but only as a bitmap
PictureBox1.Image =...
|
by: Sathyaish |
last post by:
I want to get the icon from an IE shortcut (.url) file without passing
a new WebRequest to the server.
The .url is an INI file that has the path to the original URI where
the icon file resides,...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |