473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Can't get <ToolboxBitmap> to work!

(Second posting attempt)

I have been through tons of old postings, several web sites, books, and even
tried consulting a psychic but nothing is yielding the majik answer. I'm
using VB '05 Express on a Win2K system.

The project has everything grouped under various directories. The Solution
Explorer looks like...

AProject
--My Project
--classes
----AClass.vb
--forms
----AForm.vb
--Resources
----AClass.bmp

If you haven't guessed it already I am trying to get the AClass.bmp to be
the Toolbox icon for the AClass class rather than the default gear. The
class's abbreviated version looks like...

Namespace AProject
<ToolboxBitmap(GetType(AProject.AClass), "AClass")_
Public Class AClass
Inherits System.Windows.Forms.TextBox
' Properties, Methods, and Events snipped
End Class
End Namespace

The bitmap is 15x15 16-color. (Documentation says 16x16, expert sites say
16x15 or 15x16 but don't bother to mention if that is height-by-width or
width-by-height so I took the lowest common denominator.) The Build Action
is set to Embedded Resource.

The file is listed in the Project's Resources and the Persistence is set to
Linked at compile time.

I've tried several permutations on the string value at the second parameter
position including...

AProject.Resources.AClass (w/ and w/o ".bmp")
Resources.AClass (w/ and w/o ".bmp")
AProject.AClass (w/ and w/o ".bmp")
AClass (w/ and w/o ".bmp")

I've tried relocating the BMP to the root directory of the Project and/or
the classes directory.

I've tried a fully-qualified path and file name.

I've tried everything except electroshock therapy and I'm seriously
considering even that option today.

What the heck am I doing wrong (other than wasting time on this very trivial
matter)?
Jul 21 '06 #1
10 4681
<ToolboxBitmap(GetType(AProject.AClass), "AProject.AClass.bmp")>

"MyndPhlyp" <no****@homeright.nowwrote in message
news:uY**************@TK2MSFTNGP04.phx.gbl...
(Second posting attempt)

I have been through tons of old postings, several web sites, books, and
even
tried consulting a psychic but nothing is yielding the majik answer. I'm
using VB '05 Express on a Win2K system.

The project has everything grouped under various directories. The Solution
Explorer looks like...

AProject
--My Project
--classes
----AClass.vb
--forms
----AForm.vb
--Resources
----AClass.bmp

If you haven't guessed it already I am trying to get the AClass.bmp to be
the Toolbox icon for the AClass class rather than the default gear. The
class's abbreviated version looks like...

Namespace AProject
<ToolboxBitmap(GetType(AProject.AClass), "AClass")_
Public Class AClass
Inherits System.Windows.Forms.TextBox
' Properties, Methods, and Events snipped
End Class
End Namespace

The bitmap is 15x15 16-color. (Documentation says 16x16, expert sites say
16x15 or 15x16 but don't bother to mention if that is height-by-width or
width-by-height so I took the lowest common denominator.) The Build Action
is set to Embedded Resource.

The file is listed in the Project's Resources and the Persistence is set
to
Linked at compile time.

I've tried several permutations on the string value at the second
parameter
position including...

AProject.Resources.AClass (w/ and w/o ".bmp")
Resources.AClass (w/ and w/o ".bmp")
AProject.AClass (w/ and w/o ".bmp")
AClass (w/ and w/o ".bmp")

I've tried relocating the BMP to the root directory of the Project and/or
the classes directory.

I've tried a fully-qualified path and file name.

I've tried everything except electroshock therapy and I'm seriously
considering even that option today.

What the heck am I doing wrong (other than wasting time on this very
trivial
matter)?


Jul 23 '06 #2

"Mudhead" <no*****@yourhouse.comwrote in message
news:u0**************@TK2MSFTNGP05.phx.gbl...
<ToolboxBitmap(GetType(AProject.AClass), "AProject.AClass.bmp")>
Thanks, Mudhead. (Still seeing Bottles?) Must be something to do with my
installation. It just isn't doing it for me.
[...This is a line of Indians leaving beautiful Rancho Malario-to make room
for YOU! Here's the beautiful Trail of Tears golf course...(click)...et's
talks about your car. It's screaming "Wash me, please!" Now, if you're a Mr.
Common Sense, you won't believe me when I tell you that I've got an envelope
that'll clean your car while you're driving it home to work. Well, George,
believe me this time, because this one isn't like the Austrian
self-sharpening razors. No, friends, no overheating like the tropical
fishes. No zizzing and dripping like with the dike...(click)...Hi! I'm Joe
Beets. Say, what chance does a returning deceased war veteran have for that
good-paying job, more sugar, and the free mule you've been dreaming of?
Well, think it over. Then take off your shoes. Now you can see how increased
spending opportunities mean harder work for everyone, and more of it, too!
So do your part today, Joe. Join with millions of your neighbors and turn in
your shoes! For INDUSTRY!]
Jul 23 '06 #3
Here's a funky solution. I had the same problem you did but I finally got it
to work on my machine. Here's how I did it.

Include a 16x16 bitmap and set Build Action to Embedded Resource.

Add this to your class and the compile.
<ToolboxBitmap(GetType(AClass), "AClass.bmp")_

Once compiled, open up your Bitmap (from Solution Explorer) in MSPaint and
make it smaller like 10x10 and then save it. Recompile the project.

Open it up the Bitmap again and reset it to 16x16, save and then Recompile.
It should now show up when you load it into the IDE.

You might have to do this a couple of times making it bigger and then
smaller but eventually it will work. You might also try inverting the
picture (that seemed to help). I took me about 3 or 4 times before it
started to take. I can now add any bitmap (as an embedded resource) to my
projects and it works perfectly.

I have no idea why this works, it just does.
"MyndPhlyp" <no****@homeright.nowwrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
>
"Mudhead" <no*****@yourhouse.comwrote in message
news:u0**************@TK2MSFTNGP05.phx.gbl...
><ToolboxBitmap(GetType(AProject.AClass), "AProject.AClass.bmp")>

Thanks, Mudhead. (Still seeing Bottles?) Must be something to do with my
installation. It just isn't doing it for me.
[...This is a line of Indians leaving beautiful Rancho Malario-to make
room
for YOU! Here's the beautiful Trail of Tears golf course...(click)...et's
talks about your car. It's screaming "Wash me, please!" Now, if you're a
Mr.
Common Sense, you won't believe me when I tell you that I've got an
envelope
that'll clean your car while you're driving it home to work. Well, George,
believe me this time, because this one isn't like the Austrian
self-sharpening razors. No, friends, no overheating like the tropical
fishes. No zizzing and dripping like with the dike...(click)...Hi! I'm Joe
Beets. Say, what chance does a returning deceased war veteran have for
that
good-paying job, more sugar, and the free mule you've been dreaming of?
Well, think it over. Then take off your shoes. Now you can see how
increased
spending opportunities mean harder work for everyone, and more of it, too!
So do your part today, Joe. Join with millions of your neighbors and turn
in
your shoes! For INDUSTRY!]


Jul 24 '06 #4

"Mudhead" <no*****@yourhouse.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Here's a funky solution. I had the same problem you did but I finally got
it
to work on my machine. Here's how I did it.

Include a 16x16 bitmap and set Build Action to Embedded Resource.

Add this to your class and the compile.
<ToolboxBitmap(GetType(AClass), "AClass.bmp")_

Once compiled, open up your Bitmap (from Solution Explorer) in MSPaint and
make it smaller like 10x10 and then save it. Recompile the project.

Open it up the Bitmap again and reset it to 16x16, save and then
Recompile.
It should now show up when you load it into the IDE.

You might have to do this a couple of times making it bigger and then
smaller but eventually it will work. You might also try inverting the
picture (that seemed to help). I took me about 3 or 4 times before it
started to take. I can now add any bitmap (as an embedded resource) to my
projects and it works perfectly.

I have no idea why this works, it just does.
Hmm. The methodology hints fault lies in the Resources files (or the
construction/implementation thereof). Perhaps the order of the properties or
even the names of the properties (where the presence of a reserved word as a
property name is preventing some key critical thing from happening
correctly). Initial attempts at your suggestion haven't yet yielded the
desired result but I'll keep trying things to see what happens.

In the Resources, do you leave the Persistence at the default "Linked at
compile time" or do you change that to "Embedded in .resx"?

And on the BMP's properties, do you leave the Copy to Output Directory at
the default "Do not copy" or change it to "Copy always" or "Copy if newer"?
Jul 25 '06 #5
I can assure you that this works as described. Try this instead. Delete the
resource folder from the Soultion Explorer (make sure you have a copy of the
bitmap). Once it is deleted, right click on your projects name from the
Solutions Folder and Select Add Existing File. Add your Bitmap to the
project. It will show up simply as a Bitmap file (it won't be under a
resource folder). Set the build action of the Bitmap to embedded resource
and leave everything else the same. Add the <ToolboxBitmap(GetType(AClass),
"AClass.bmp")_ to the top of your class. Then compile. Then do the
procedures that I described. I can show you a my test project if you want
to see it how it should look.


"MyndPhlyp" <no****@homeright.nowwrote in message
news:O0**************@TK2MSFTNGP04.phx.gbl...
>
"Mudhead" <no*****@yourhouse.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>Here's a funky solution. I had the same problem you did but I finally got
it
>to work on my machine. Here's how I did it.

Include a 16x16 bitmap and set Build Action to Embedded Resource.

Add this to your class and the compile.
<ToolboxBitmap(GetType(AClass), "AClass.bmp")_

Once compiled, open up your Bitmap (from Solution Explorer) in MSPaint
and
make it smaller like 10x10 and then save it. Recompile the project.

Open it up the Bitmap again and reset it to 16x16, save and then
Recompile.
>It should now show up when you load it into the IDE.

You might have to do this a couple of times making it bigger and then
smaller but eventually it will work. You might also try inverting the
picture (that seemed to help). I took me about 3 or 4 times before it
started to take. I can now add any bitmap (as an embedded resource) to my
projects and it works perfectly.

I have no idea why this works, it just does.

Hmm. The methodology hints fault lies in the Resources files (or the
construction/implementation thereof). Perhaps the order of the properties
or
even the names of the properties (where the presence of a reserved word as
a
property name is preventing some key critical thing from happening
correctly). Initial attempts at your suggestion haven't yet yielded the
desired result but I'll keep trying things to see what happens.

In the Resources, do you leave the Persistence at the default "Linked at
compile time" or do you change that to "Embedded in .resx"?

And on the BMP's properties, do you leave the Copy to Output Directory at
the default "Do not copy" or change it to "Copy always" or "Copy if
newer"?


Jul 25 '06 #6

"Mudhead" <no*****@yourhouse.comwrote in message
news:em**************@TK2MSFTNGP03.phx.gbl...
I can assure you that this works as described. Try this instead. Delete
the
resource folder from the Soultion Explorer (make sure you have a copy of
the
bitmap). Once it is deleted, right click on your projects name from the
Solutions Folder and Select Add Existing File. Add your Bitmap to the
project. It will show up simply as a Bitmap file (it won't be under a
resource folder). Set the build action of the Bitmap to embedded resource
and leave everything else the same. Add the
<ToolboxBitmap(GetType(AClass),
"AClass.bmp")_ to the top of your class. Then compile. Then do the
procedures that I described. I can show you a my test project if you want
to see it how it should look.
It has to be something hosed with my installation then.

I created a new project, kept the default empty Form, added a Class named
DummyClass, added DummyClass.BMP (16x16, 16-color depth) to the Project
changing the Build Action to Embedded Resource, added
<ToolboxBitmap(GetType(DummyClass), "DummyClass.bmp")to the Class
definition plus "Inherits System.Windows.Forms.RichTextBox" to the Class
body (so that it appears as an insertable object in the ToolBox). Everything
is defaulted (with the minor exceptions already noted). No Namespace
declarations or anything else. Saved everything, did a build, flipped back
to the empty Form to get the ToolBox display. No love. Scaled the BMP down
to 10x10, recompiled. Still no love. Rescaled back to 16x16 and recompiled.
Still no love. Did that a few times with no change in the results. Just for
grins, exited and restarted VB 2005 Express. No good. Tried resetting the
ToolBox. Still not doing it.

The funny thing (in a masochistic sort of way) is that everything else
appears to be working just fine. If the installation were blown I would
expect to see other symptoms raising their ugly head.

I'd appreciate looking at your test project. The email address is MyndPhlyp
at yahoo dot com.
Jul 25 '06 #7
I'll send it. When you scale the bitmap back up to 16x16 make sure you fill
it with a random color then invert the colors and save. Also, you said you
were using it in a Windows Form project? That's probably your problem. When
I do it that way, I get the gears also. You sould create a control dll and
test it in another form outside your project. Then it will show up.
"MyndPhlyp" <no****@homeright.nowwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>
"Mudhead" <no*****@yourhouse.comwrote in message
news:em**************@TK2MSFTNGP03.phx.gbl...
>I can assure you that this works as described. Try this instead. Delete
the
>resource folder from the Soultion Explorer (make sure you have a copy of
the
>bitmap). Once it is deleted, right click on your projects name from the
Solutions Folder and Select Add Existing File. Add your Bitmap to the
project. It will show up simply as a Bitmap file (it won't be under a
resource folder). Set the build action of the Bitmap to embedded resource
and leave everything else the same. Add the
<ToolboxBitmap(GetType(AClass),
>"AClass.bmp")_ to the top of your class. Then compile. Then do the
procedures that I described. I can show you a my test project if you
want
to see it how it should look.

It has to be something hosed with my installation then.

I created a new project, kept the default empty Form, added a Class named
DummyClass, added DummyClass.BMP (16x16, 16-color depth) to the Project
changing the Build Action to Embedded Resource, added
<ToolboxBitmap(GetType(DummyClass), "DummyClass.bmp")to the Class
definition plus "Inherits System.Windows.Forms.RichTextBox" to the Class
body (so that it appears as an insertable object in the ToolBox).
Everything
is defaulted (with the minor exceptions already noted). No Namespace
declarations or anything else. Saved everything, did a build, flipped back
to the empty Form to get the ToolBox display. No love. Scaled the BMP down
to 10x10, recompiled. Still no love. Rescaled back to 16x16 and
recompiled.
Still no love. Did that a few times with no change in the results. Just
for
grins, exited and restarted VB 2005 Express. No good. Tried resetting the
ToolBox. Still not doing it.

The funny thing (in a masochistic sort of way) is that everything else
appears to be working just fine. If the installation were blown I would
expect to see other symptoms raising their ugly head.

I'd appreciate looking at your test project. The email address is
MyndPhlyp
at yahoo dot com.


Jul 25 '06 #8

"Mudhead" <no*****@yourhouse.comwrote in message
news:uH**************@TK2MSFTNGP05.phx.gbl...
I'll send it. When you scale the bitmap back up to 16x16 make sure you
fill
it with a random color then invert the colors and save. Also, you said you
were using it in a Windows Form project? That's probably your problem.
When
I do it that way, I get the gears also. You sould create a control dll and
test it in another form outside your project. Then it will show up.
<???>test it in another form outside your project </???>

How does one do that without utilizing a Windows Form project? I suspect you
are actually saying that I should maintain the Class as a separate project,
which I normally do anyway.

This most recent dummy project was a deviation from the norm though taking a
"default path" approach of creating a single Form and a single Class within
the same Windows Application project.

Attempting to recreate your results, starting with my "default path" dummy
project, I did a File =Add =Existing Project to link your project into
my project. Had to Build =Rebuild Solution to get ResourceTest to show up
in the Toolbox. Still showing the gear in both Components sections of the
Toolbox. Resizing and inverting colors is having no effect (other than
keeping me busy).

I did notice that your bitmap uses 24-bit 16M colors as opposed to the
recommended 4-bit 16 colors I have seen at various "expert" web sites. Also
contrary to "expert" recommendations is that the bitmap's name does not
equal the Class's name.

<heavysigh />

I take your word for it that this stuff works for your installation but I am
going to give up trying to make it work at this end. I have already wasted
far too much time and effort (at both our ends) on this very trivial matter.
While it would be nice to use unique icons, I can get by without them.
Perhaps somewhere along the line somebody will identify where the bug lies
and the resolution. This isn't the first time (nor, I suspect, the last)
things from Seattle failed to work as advertised.

Thanks for your time and patience on this. Time for us to get back to doing
something productive.
Jul 25 '06 #9
This is probably not your situation but I have had trouble getting embedded
resources to work when I add a project, say project "A", to my current
solution then try to add an embedded resource to Project "A" when the
solution for the first project is open. I have to close the open project
then open Project "A" separately, add the embedded resource them recompile
Project "A". When I re-open my original solution, I then have the resource
in Project "A" available.
--
Dennis in Houston
"MyndPhlyp" wrote:
>
"Mudhead" <no*****@yourhouse.comwrote in message
news:uH**************@TK2MSFTNGP05.phx.gbl...
I'll send it. When you scale the bitmap back up to 16x16 make sure you
fill
it with a random color then invert the colors and save. Also, you said you
were using it in a Windows Form project? That's probably your problem.
When
I do it that way, I get the gears also. You sould create a control dll and
test it in another form outside your project. Then it will show up.

<???>test it in another form outside your project </???>

How does one do that without utilizing a Windows Form project? I suspect you
are actually saying that I should maintain the Class as a separate project,
which I normally do anyway.

This most recent dummy project was a deviation from the norm though taking a
"default path" approach of creating a single Form and a single Class within
the same Windows Application project.

Attempting to recreate your results, starting with my "default path" dummy
project, I did a File =Add =Existing Project to link your project into
my project. Had to Build =Rebuild Solution to get ResourceTest to show up
in the Toolbox. Still showing the gear in both Components sections of the
Toolbox. Resizing and inverting colors is having no effect (other than
keeping me busy).

I did notice that your bitmap uses 24-bit 16M colors as opposed to the
recommended 4-bit 16 colors I have seen at various "expert" web sites. Also
contrary to "expert" recommendations is that the bitmap's name does not
equal the Class's name.

<heavysigh />

I take your word for it that this stuff works for your installation but I am
going to give up trying to make it work at this end. I have already wasted
far too much time and effort (at both our ends) on this very trivial matter.
While it would be nice to use unique icons, I can get by without them.
Perhaps somewhere along the line somebody will identify where the bug lies
and the resolution. This isn't the first time (nor, I suspect, the last)
things from Seattle failed to work as advertised.

Thanks for your time and patience on this. Time for us to get back to doing
something productive.
Jul 25 '06 #10

"Dennis" <De****@discussions.microsoft.comwrote in message
news:39**********************************@microsof t.com...
This is probably not your situation but I have had trouble getting
embedded
resources to work when I add a project, say project "A", to my current
solution then try to add an embedded resource to Project "A" when the
solution for the first project is open. I have to close the open project
then open Project "A" separately, add the embedded resource them recompile
Project "A". When I re-open my original solution, I then have the
resource
in Project "A" available.
Yeah, that's an ongoing "theme" with this IDE. The easiest way I've found
around that is to go ahead and add in all the various projects of interest,
make sure the main project is the Startup Project, do a Build =Clean
Solution, and a Build =Rebuild Solution (the latter of which could
probably just as well be a Build =Build Solution).

The Clean removes any existing embeddable components from the Toolbox. The
Rebuild/Build puts them right back plus whatever was missing due to new
project inclusions. Once things have been rebuilt the objects are readily
available.

It is very annoying, to say the least. I am used to VB6 where I could toss
together a UC and immediately have it available for inclusion. With this IDE
a Build has to be done before the object becomes available even though you
are not generating a DLL or OCX.

Another annoyance in getting homegrown objects to embed is that the object's
qualifiers (namespace paths) tend to get messed up in the *.Designer.VB
files. Haven't found a solution to that one yet. I end up having to manually
fix them.

That is by far not an all-inclusive list however. Since I started down the
VB.Net path I have discovered /*many*/ 4-lettered words even God has never
heard before.
Jul 26 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sundown | last post by:
I am trying to create a custom button control for the web that, when clicked, disables and changes the text of itself and a bunch of other controls (in the collection). My goal is to end up with a...
0
by: Adam Dockter | last post by:
I want my custom controls to have customer bitmaps but I can't get them to work if I try to pull the icon from a resource file. I know that I can add the icon to the project as an embedded...
4
by: steve bull | last post by:
I have created a UserControl and added it to my toolbox. It appears in the toolbox with the icon I created for it. The problem is that when I drag the control onto a form no code is generated. If I...
1
by: Jeff | last post by:
Hello, I have developed a library of controls but for the life of me cannot get ToolboxBitmapAttribute to work -- my image simply will not display in the toolbox of any project using my...
4
by: OpticTygre | last post by:
I have a control I built, for which I would like to add a tool bar icon, but for some reason, it's not working correctly. There is no default namespace (I removed it from the properies page of...
0
by: MyndPhlyp | last post by:
I can't believe this is so difficult. I have been through tons of old postings, several web sites, books, and even tried consulting a psychic but nothing is yielding the majik answer. I'm using VB...
2
by: rotsj | last post by:
Hello, I would like to make my own dropdownlist and add a collection as a generic List. When I enter items @ designtime, @ runtime they are gone. Can anyone tell me please what the problem...
2
by: Nathan Sokalski | last post by:
I am attempting to create icons for controls I have created using VB.NET by using the System.Drawing.ToolboxBitmap attribute. I have managed to do this in C# by specifying the path to the *.ico...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.