Adding bitmaps to project

D

Derek Martin

Hi there, I have a couple of bitmaps that are called in my project that I
need to use. They were added to my solution as existing objects and are
located in the same folder as the rest of the vb files.

I set their Build Action to Embedded Resource and compiled without any
errors, however, when calling them, like this inside Initialize Components:

myclosebutton.SetCloseBitmap(New Bitmap(MyClass.GetType(), "close.bmp"),
Color.FromArgb(255, 0, 255), New Point(127, 8))

I get this error:

An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll
Additional information: Resource 'close.bmp' could not be found in class
'InnerView.InnerView.main'.

Help!???
Thanks,
Derek
 
W

William Ryan eMVP

Derek:

off the top of my head, I'm not sure. I think you need to reference the
project though. Here's the style I use regularly to get the info (not
saying this is better, but it definitely works)
case ImageName.RecordDisabled:
return new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResource
Stream("Project.Resource.jpg"));
 
D

Derek Martin

Hmmm...well, I tried something similar to that and also went and found some
examples on the internet, nothing seems to be different in my setup than the
examples.

My startup object isn't the form that these are in, could that be the
trouble?

Thanks!
Derek
 
D

Derek Martin

I decided after fighting with it for quite some time to create a bitmap
right from within VS. Did an Add New Item, Bitmap File and saved it to the
solution. Properties set to Embedded Resource and changed the line to look
like this:
taskbarNotifier1.SetCloseBitmap(New Bitmap(MyClass.GetType(),
"Bitmap1.bmp"), Color.FromArgb(255, 0, 255), New Point(127, 8))
Same error - I MUST be doing something very small and wrong
consistently...anyone???

Thanks!
Derek
 
W

William Ryan eMVP

Derek: I just used your bitmap name and stuck it in a project called
WindowsApplication10. I added a bitmap I had and called it Close.bmp to
match your situation. Worked without a glitch..you may want to use this
syntax:

Dim testBitmap As New
Bitmap(Reflection.Assembly.GetExecutingAssembly.GetManifestResourceStream("W
indowsApplication10.Close.bmp"))

Me.Button1.Image = testBitmap
 
D

Derek Martin

Okay, I got that working and that led me down a few more paths...I am
running the method that is calling my bitmap popup (see the toaster posts
below in NG if interested) in a thread which is not allowing it to push it
out correctly - jumps right over it.

SO - thanks so much for you help!!!! Now I just have to figure out how to
make that thing work in a thread and I am in business!

:)

Derek
 
D

Derek Martin

By the way, to get it to work, I had to put the bmp in the exe directory of
the project and make this line:

taskbarNotifier1.SetCloseBitmap(New Bitmap(MyClass.GetType(), "close.bmp"),
Color.FromArgb(255, 0, 255), New Point(127, 8))
Say this instead:
taskbarNotifier1.SetCloseBitmap("close.bmp", Color.FromArgb(255, 0, 255),
New Point(127, 8))
It works, but the downside is, obviously, the bmp isn't included in the exe
file which would allow someone to change it and that's bad, but I cannot for
the life of me get that first line example to work.
Any ideas?
Thanks,
Derek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top