_BBB...
I have ran into this problem before. The solution is not complicated, but
is hard to locate in the documentation. Here is what I have found and it
works for me...
I have added a folder to my project named "Images" and in this folder, I
have added a few JPG files. I then set the Build Action property for each
JPG file to "Embedded Resource". I placed this code on the load of a form
to set the Background image of the form to one of the JPG images (the one
named Sunset.jpg).
Dim thisExe As System.Reflection.Assembly
thisExe = System.Reflection.Assembly.GetExecutingAssembly()
Dim file As System.IO.Stream =
thisExe.GetManifestResourceStream(thisExe.GetName.Name &
".Sunset.jpg")Me.BackgroundImage = Image.FromStream(file)
Note that the function GetManifestResourceStream uses case sensitive
parameters. Therefore, ".Sunset.jpg" is not the same as ".sunset.jpg".
Here is some code that will cycle through the list of embedded resources.
Dim thisExe As System.Reflection.Assembly
thisExe = System.Reflection.Assembly.GetExecutingAssembly()
Dim resources() As String = thisExe.GetManifestResourceNames()
Dim resource As String = ""
For Each resource In resources
Debug.WriteLine(resource & Microsoft.VisualBasic.ControlChars.CrLf)
Next
I hope this helps.
Roger.Smith
[quoted text, click to view] "_BBB" <_BBB@nospam.org> wrote in message
news:i1poq0t01ek5is4q450c503oa1g0vuh9hi@4ax.com...
> I'm coming over from a background in VC++, and in general I've been
> pleased with the simplicity of the .NET environment. Not here.
>
> I've done google searches on this subject (loading bitmaps from a local
> resource) and always come up with complex solutions. This can't be right.
> Everyone packs bitmaps and other graphics and resources, integral to small
> executables, right?
>
> Setting up a local resource folder, loading in graphics, and setting their
> properties to 'Embedded Resource' would seem to incorporate them, as
> expected.
>
> Then what? It's tough to make 'FromResource' happy. There's got to be
> some simple solution to this.
>