Solved

draw an icon on the form from resources

Posted on 2010-09-24
2
380 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
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 500 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

713 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