Component Ion

G

Guest

Hello,

I have made a component to use in a form.

I have add the component to the tools bar in Visual Studio 2005 to use in
more than one project.

I want to change the Icon asigned automatically by VS2005 to the component.
It seems like a flower.

How I can assign my own icon to the component?.

Thanks in advance.
 
J

Jeffrey Tan[MSFT]

Hi Tomas,

Based on my understanding, you want to assign a customized ICON to your own
component, so that it will be displayed in the ToolBox and designer
component tray. If I have misunderstood you, please feel free to tell me,
thanks.

This is mainly a .Net Winform design-time feature. You may leverage the
ToolboxBitmapAttribute to get this done. Please refer to "Attributes"
section in the link below:
"Building Windows Forms Controls and Components with Rich Design-Time
Features"
http://msdn.microsoft.com/msdnmag/issues/03/04/design-timecontrols/default.a
spx

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

I have this error:

Error C2337 'attribute name' : attribute not found.

This attribute name is not avalaible on this version of Visual Studio.

Where I can find the list of attributes available?
 
J

Jeffrey Tan[MSFT]

Hi Tomas,

Thanks for your feedback.

Can you provide a little sample project to help me reproduce this error?

I have created a CLR C++ Winform Control Library project and apply the
attribute like below:

[ToolboxBitmap("c:\\ico1.ico")]
public ref class CLIControlControl : public
System::Windows::Forms::UserControl

This project compiles without any problem.

In another C++ CLR Winform project, I added the CLIControlControl in the
ToolBox manually, the icon will display well.

Note: the size of the bitmap that you used should be 16 by 16.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
B

Ben Voigt

Tomas said:
I have this error:

Error C2337 'attribute name' : attribute not found.

You might need to use the full name,
::System::Drawing::ToolboxBitmapAttribute and/or add a reference to
System.Drawing.dll
 
G

Guest

You might need to use the full name,
::System::Drawing::ToolboxBitmapAttribute and/or add a reference to
System.Drawing.dll

Yes, you are right, I have made this:

[System::Drawing::ToolboxBitmapAttribute("C:\\app.ico") ]

My Icon is 16x16 size, but not all colors are displayed in the toolbar, but
it does not matter.

Thanks.
 
J

Jeffrey Tan[MSFT]

Hi Tomas,

Thanks for your feedback.

Oh, do you use "Windows Control Library" project type to create your
component? If you are using "Windows Control Library" project type, there
will be an already "using namespace System::Drawing;" in the file, so the
full path of "System::Drawing::ToolboxBitmapAttribute" is need. So I
suspect you are creating "Windows Class Library" project type, which will
not add "using namespace System::Drawing".

Anyway, glad to see you have figured it out. Regarding the further color
not displayed issue, I assume VS IDE can only support 16 colors in the ICO
file, so some other colors may not be displayed correct on it.

If you still need any help or have any concern, please feel free to tell
me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Oh, do you use "Windows Control Library" project type to create your
component? If you are using "Windows Control Library" project type, there
will be an already "using namespace System::Drawing;" in the file, so the
full path of "System::Drawing::ToolboxBitmapAttribute" is need. So I
suspect you are creating "Windows Class Library" project type, which will
not add "using namespace System::Drawing".

I have made this:

[ System::Drawing::ToolboxBitmapAttribute("C:\\app.ico") ]
public ref class WindowState : public System::ComponentModel::Component
{
....
};

It is a class that save/restore the window size and position for every form
in the application.

Thanks for your help.
 
J

Jeffrey Tan[MSFT]

Hi Tomas,

Thanks for your clarify.

Yes, class library component project does not using the namespace of
System::Drawing by default, so you may have to add it yourself or use the
full namespace to specify the ToolboxBitmapAttribute.

If you need further help or any concern, please feel free to post, thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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