?
Solved

draw an icon on the form from resources

Posted on 2010-09-24
2
Medium Priority
?
384 Views
Last Modified: 2012-05-10
Hi there, i am trying to retrieve an icon from my resources in order to draw it via GDI...

SO here is what i do and i keep getting null

my resource's name is tram and the icon is tram.ico


Dim list = System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceNames()

Dim assembly As System.Reflection.Assembly =Me.GetType().Assembly

Me.theIcon = GetEmbeddedIcon(assembly.GetName().Name & ".tram.ico")

Form1.gMyGraphics.DrawIcon(theIcon, 20, 20)



Function GetListOfEmbeddedResources() As Array
        Return _
         System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceNames
    End Function
    Function GetEmbeddedIcon(ByVal strName As String) As Icon
        Return New Icon(System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream(strName))
    End Function

Open in new window

0
Comment
Question by:ioustinos_sarris
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 33754368
There is a trick actually in the constructor of the Icon class you can specify the name of the resource. See code block.
Make sure that you right clicked on the resource in the solution explorer and have set the "Build Action" property to "Embedded Resource"

Dim ico As New Icon(GetType(Form1), "blankcd.ico")
Me.Icon = ico

Open in new window

0
 
LVL 7

Accepted Solution

by:
klakkas earned 2000 total points
ID: 33754369
Hi.

Why not just go with my.Resources.Tram?
This will return the image you want, ready to be drawn by GDI...
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

765 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