图标文件 [英] Icon files

查看:47
本文介绍了图标文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我将新项目(解决方案项目)添加到我的项目及其图标(.ico),

我在编码时如何引用该文件,我是否还需要添加它是一个图像控件,我不希望该文件成为.resx文件的一部分。

当我可以使用加载所有图像时它就像VB6一样来自资源文件。

Lou

解决方案

" Lou" <螺******** @ comcast.net> schrieb:

如果我向项目添加一个新项目(解决方案项目)及其图标(.ico),
我在编码时如何引用该文件,我有吗?还要将它添加到图像控件中,我不希望该文件成为.resx文件的一部分。
当我可以使用加载我的所有图像时,它就像VB6资源文件。




请参阅:


< URL:http://groups.google.de/group/ microsoft.public.dotnet.languages.vb / msg / 7f73b72ab0a88452>


-

MS Herfried K. Wagner

MVP < URL:http://dotnet.mvps.org/>

VB< URL:http://classicvb.org/petition/>


>如果我向项目添加一个新项目(解决方案项)及其图标(.ico),

我在编码时如何引用该文件




最简单的方法如下。


1.将.ico文件添加到项目中。

2 。对于每个图标文件,将构建操作设置为嵌入资源。这个

将包含你的.exe文件中的.ico文件(我的直接体验只有

与windows form .exe文件,但我希望这可以与其他应用程序一起使用

类型)。

3.在你的程序中,你可以通过下面显示的代码片段获得一个图标对象

。如果图标文件的名称为xxx.ico,并且您的应用名称为

yyy,则.exe文件中图标资源的名称为yyy.xxx.ico。


dim s as string =" yyy.xxx.ico" ''你的名字取代yyy和xxx

dim MyIcon = New

Icon(System.Reflection.Assembly.GetExecutingAssemb ly.GetManifestResourceStream(s))


现在你可以设置一个表单的图标,如:someform.Icon = MyIcon。


我在哪里设置构建操作?

" AMercer" < AM ***** @ discussions.microsoft.com>在消息中写道

news:6E ********************************** @ microsof t.com ...

如果我向项目中添加一个新项目(解决方案项)及其图标(.ico),
怎么能我在编码时引用该文件



最简单的方法如下:

1.将.ico文件添加到项目中。
2.对于每个图标文件,将构建操作设置为嵌入资源。这个
将包含你的.exe文件中的.ico文件(我的直接体验仅仅是使用windows form .exe文件,但我希望这可以与其他app
类型一起使用)。
3.在你的程序中,你可以通过下面显示的代码片段获得一个图标对象。如果图标文件xxx.ico的名称和您的应用程序名称是yyy,则.exe文件中图标资源的名称为
yyy.xxx.ico。

dim s as string =" yyy.xxx.ico" ''你的名字取代yyy和xxx
dim MyIcon = New
Icon(System.Reflection.Assembly.GetExecutingAssemb ly.GetManifestResourceStream(s))

现在你可以设置一个表单's的图标如:someform.Icon = MyIcon。



if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding, Do I have to also add it to
an image control, I don''t want the file to be part of the .resx file.
Its like VB6 when I could use load all my images from a resource file.
Lou

解决方案

"Lou" <lo********@comcast.net> schrieb:

if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding, Do I have to also add it
to
an image control, I don''t want the file to be part of the .resx file.
Its like VB6 when I could use load all my images from a resource file.



See:

<URL:http://groups.google.de/group/microsoft.public.dotnet.languages.vb/msg/7f73b72ab0a88452>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


> if I add a new item (Solution Items) to my project and its an icon(.ico),

how can I reference that file when I am coding



The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource". This
will include the .ico file in your .exe file (my direct experience is only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is "yyy.xxx.ico".

dim s as string = "yyy.xxx.ico" '' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Reflection.Assembly.GetExecutingAssemb ly.GetManifestResourceStream(s))

Now you can set a form''s icon like: someform.Icon=MyIcon.


Where do I set the build Action?
"AMercer" <AM*****@discussions.microsoft.com> wrote in message
news:6E**********************************@microsof t.com...

if I add a new item (Solution Items) to my project and its an icon(.ico),
how can I reference that file when I am coding



The easiest thing to do is as follows.

1. Add the .ico file(s) to your project.
2. For each icon file, set the build action to "embedded resource". This
will include the .ico file in your .exe file (my direct experience is only
with windows form .exe files, but I expect this will work with other app
types).
3. In your program, you can get an icon object via the code fragment
shown
below. If the name of the icon file xxx.ico, and the name of your app is
yyy, then the name of the icon resource in your .exe file is
"yyy.xxx.ico".

dim s as string = "yyy.xxx.ico" '' your names replace yyy and xxx
dim MyIcon = New
Icon(System.Reflection.Assembly.GetExecutingAssemb ly.GetManifestResourceStream(s))

Now you can set a form''s icon like: someform.Icon=MyIcon.



这篇关于图标文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆