By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,683 Members | 1,387 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,683 IT Pros & Developers. It's quick & easy.

Icons in VB

P: n/a
Hi,

I have implemented a COM object in .NET, and I simply want
to load an icon resource and pass back an IPictureDisp to
clients. What is the esiest way to do this? I had used
LoadResPicture in VB, but I havent been able to
create/load an icon resource in VB .NET. I'm sure that
this should be simple....by so far I am failing miserably!

Any suggestions? The documentation babbles on and on
about .resx, .resource and silly little conversion
programs but doesn't really give any clear examples...
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Stephen,

There's a forum on VS .NET add-ins:

http://groups.yahoo.com/groups/vsnetaddin

and there has been a topic recently where a multi-purpose class doing this
..NET <-> IPictureDisp translation was discussed. You could also conduct a
search on "IPictureDisp" in this forum - as I have also seen other postings
on the same topic.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Stephen Turner" <st*****@symyx.com> wrote in message
news:09****************************@phx.gbl...
Hi,

I have implemented a COM object in .NET, and I simply want
to load an icon resource and pass back an IPictureDisp to
clients. What is the esiest way to do this? I had used
LoadResPicture in VB, but I havent been able to
create/load an icon resource in VB .NET. I'm sure that
this should be simple....by so far I am failing miserably!

Any suggestions? The documentation babbles on and on
about .resx, .resource and silly little conversion
programs but doesn't really give any clear examples...


Nov 20 '05 #2

P: n/a
COM is, uh, outside my area of expertise (come to think of it, so far
everything in VB is), and I dunno if it's close to what you need, but
here's how I bundled an icon into an executable and accessed it:

----------

1. Added the icon file to the solution.
2. Highlighted the icon in the Solution Explorer, and changed the Build
Action property to "Embedded Resource".
3. In a module, inserted a function to retrieve the icon:

Imports System.Reflection.Assembly

Public Function EmbeddedIcon(ByVal Name as String) as Icon

Return New
Icon(GetExecutingAssembly.GetManifestResourceStrea m(Name))

End Function

4. Elsewhere in the program, accessed the icon like so:

TrayIcon.Icon = EmbeddedIcon("<namespace>.<icon-name>.ico")

----------

Obviously, or maybe not, <namespace> stands for the namespace, and
"<icon-name>.ico" stands for the file name of the icon I added in step
1. Apparently it's all case-sensitive, so be careful with that.

The procedure worked like a charm for me, but I'm a little
uncomfortable with it, because I got lucky in specifying the
namespace -- I just used the project name, and it was fine. I'm not
certain yet how multiple namespaces might be created and used in a
project.

Plenty to learn, plenty to learn...
Stephen Turner wrote in message...

I have implemented a COM object in .NET, and I simply
want to load an icon resource and pass back an
IPictureDisp to clients. What is the esiest way to do
this? I had used LoadResPicture in VB, but I havent been
able to create/load an icon resource in VB .NET. I'm
sure that this should be simple....by so far I am failing
miserably!

Any suggestions? The documentation babbles on and on
about .resx, .resource and silly little conversion
programs but doesn't really give any clear examples...

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.