
Resource File Usage is an absolute nightmare
Main Program code, get an icon (dropped this icon into the solution explore
so it became a resource for this project)
cmdInformation.Image = GetIcon(Me, ".InfoEnabled.ico").ToBitmap
Function Code for getting the icon out of the Resource.
Public Function GetIcon(ByVal Ob As Object, ByVal szBitmapName As String) As
System.Drawing.Icon
Dim Ass As Reflection.Assembly
Dim appIcon As System.Drawing.Icon
Ass = Ob.GetType().Module.Assembly
appIcon = New
System.Drawing.Icon(Ass.GetManifestResourceStream("YourClass/App Name" &
szBitmapName))
Return appIcon
End Function
Hope this helps
Andrew Stewart
Quote:
> I have posted this question before and thought it had been answered but
have
> come to use resource files again only to find all the examples on this
group
> don't work or are not applicable.
> ALL I WANT TO DO IS EMBEDD A ICON/BITMAP RESX FILE WITH MY APPLICATION AND
> THEN READ IT INTO SOME SPECIFIC VARIABLES.
> Please,please could some one show me an example of how to do this. PLEASE
DO
> NOT POST A LINK TO THE PATHETIC HELP FILES WHICH I HAVE JUST WASTED 4
HOURS
> ON AND GOT NO WHERE.
> I thought is would be a simple
> Attempt 1
> Dim _Ico as icon
> Dim rm As ResourceManager =
> ResourceManager.CreateFileBasedResourceManager("MyRes", ".", Nothing)
> _icon = ctype(rm.GetObject("Save1.ico"),icon)
> Attempt 2
> Dim _Ico as icon
> Dim rm As New
Resources.ResourceManager("MyRes",System.Reflection.Assembly.GetExecutingAs
s
Quote:
> embly)
> _ icon =ctype( rm.GetObject("Save1.ico"),icon)
> Both cases fail on the _icon assignment saying the resource file could not
> be found. The usual "please check that it is linked" unhelpful help
> response.
> The MyRes.resx file is an embedded resource in my project.
> It's nothing to do with the file format either as I have tried it as an
> object and bitmap. Still no good.
> Why does this not work and how can I lower my {*filter*} pressure!!!!
> Thanks