Resolve little picture of control.

M

Mr. X.

Hello.
On the VS. 2008 IDE there is a toolbox, that shows all the components.
At each element description on the left side, there is a picture of the
element.
Can I resolve for an element the little picture ?
How can I do that ?

Thanks :)
 
J

Jeff Johnson

On the VS. 2008 IDE there is a toolbox, that shows all the components.
At each element description on the left side, there is a picture of the
element.
Can I resolve for an element the little picture ?
How can I do that ?

I don't understand the question. Are you trying to provide an image for a
custom control that you're going to add to the toolbox? Or are you writing
some sort of IDE add-in and you want to examine the contents of the toolbox
and get images from the items? I just don't know what you mean by "resolve."
 
M

Mr. X.

Sorry for my bad English.
Is there any way to "know" what is the picture behind a control,
that I can see, exactly as the toolbox of IDE show a list of component and
picture besides each control?

If there is no such build-in function, is there any pictures-libraries, that
are exactly (or mostly) the same picture as the toolbox of the IDE shows.
I need to do the same thing (something like that kind of toolbox).

Even if my English is so bad, I hope you understand the concept of the above
question.

Thanks :)
 
J

Jeff Johnson

Sorry for my bad English.
Is there any way to "know" what is the picture behind a control,
that I can see, exactly as the toolbox of IDE show a list of component and
picture besides each control?

You would have to examine the resources of the assembly that provides the
control. They probably have the System.Drawing.ToolboxBitmapAttribute set,
so you could use reflection and search for that.
 
J

Jeff Johnson

You would have to examine the resources of the assembly that provides the
control. They probably have the System.Drawing.ToolboxBitmapAttribute set,
so you could use reflection and search for that.

When I said "they" I meant any controls in the assembly, not the resources
themselves. Sorry for any confusion.
 
M

Mr. X.

Great.
I used : System.Drawing.ToolboxBitmapAttribute.GetImageFromResource.
(Amazing that Microsoft company thought of all little things, even for
programmers).

I see 2 problems.
1. I don't know what is the type of the Pointer ? How can I show it's
toolbox-bitmap ?
2. I created a user control, but the above
System.Drawing.ToolboxBitmapAttribute.GetImageFromResource doesn't get it's
bitmap. Why ? Is there any common way to create user-control?

Thanks :)
 
J

Jeff Johnson

Great.
I used : System.Drawing.ToolboxBitmapAttribute.GetImageFromResource.
(Amazing that Microsoft company thought of all little things, even for
programmers).

I see 2 problems.
1. I don't know what is the type of the Pointer ? How can I show it's
toolbox-bitmap ?
2. I created a user control, but the above
System.Drawing.ToolboxBitmapAttribute.GetImageFromResource doesn't get
it's bitmap. Why ? Is there any common way to create user-control?

The static method GetImageFromResource() seems to require you to know a lot
about the assembly in order to retrieve a resource. It looks like you'd be
better off using the instance method GetImage(Type). This assumes that you'd
be using reflection to first obtain the types in the assembly and then, as
you loop through the types, checking to see if each one has a
ToolboxBitmapAttribute assigned. Then you'd get that ToolboxBitmapAttribute
instance and call the method, passing the type you're currently dealing
with. Off the top of my head I don't know if you'd need to instantiate the
type to get a ToolboxBitmapAttribute instance; I don't recall ever dealing
with attributes like that.
 
K

kndg

If there is no such build-in function, is there any pictures-libraries,
that are exactly (or mostly) the same picture as the toolbox of the IDE
shows.
I need to do the same thing (something like that kind of toolbox).

Microsoft has compiled (nearly) all the images used in the Visual Studio
IDE and packaged it into a nice zip file. It is in below folder,

[Visual Studio Installation Folder]\Common7\VS2008ImageLibrary\1033

The images you are looking for are probably under
"Objects\24bit_bitmaps" subfolder. Check the file that name starts with
"Control_".

Regards.
 
M

Mr. X.

Thank you.

Jeff Johnson said:
The static method GetImageFromResource() seems to require you to know a
lot about the assembly in order to retrieve a resource. It looks like
you'd be better off using the instance method GetImage(Type). This assumes
that you'd be using reflection to first obtain the types in the assembly
and then, as you loop through the types, checking to see if each one has a
ToolboxBitmapAttribute assigned. Then you'd get that
ToolboxBitmapAttribute instance and call the method, passing the type
you're currently dealing with. Off the top of my head I don't know if
you'd need to instantiate the type to get a ToolboxBitmapAttribute
instance; I don't recall ever dealing with attributes like that.
 
J

Jeff Johnson

If there is no such build-in function, is there any pictures-libraries,
that are exactly (or mostly) the same picture as the toolbox of the IDE
shows.
I need to do the same thing (something like that kind of toolbox).

Microsoft has compiled (nearly) all the images used in the Visual Studio
IDE and packaged it into a nice zip file. It is in below folder,

[Visual Studio Installation Folder]\Common7\VS2008ImageLibrary\1033

The images you are looking for are probably under "Objects\24bit_bitmaps"
subfolder. Check the file that name starts with "Control_".

Wow, I totally missed that part of his reply. Now I finally understand WHY
he's try to do this.
 

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