ToolBoxBitMap Attribute
-
How to Use the ToolBoxBitMap Attribute for a control Created using ManC++. I tried the way it is done in C#, but I get an Error (Undeclared Identifier) for the Type parameter of ToolBoxBitMap Attribute .
namespace XYZ
{
[ToolboxBitmap(__typeof(MyControl))]
public __gc class MyControl : public UserControl
{
//
};
}The Project also have a bitmap(with the name MyControl.bmp) as a resource. Where am I going wrong ? Thanks, Firoz
-
How to Use the ToolBoxBitMap Attribute for a control Created using ManC++. I tried the way it is done in C#, but I get an Error (Undeclared Identifier) for the Type parameter of ToolBoxBitMap Attribute .
namespace XYZ
{
[ToolboxBitmap(__typeof(MyControl))]
public __gc class MyControl : public UserControl
{
//
};
}The Project also have a bitmap(with the name MyControl.bmp) as a resource. Where am I going wrong ? Thanks, Firoz
Firoz -- I've been meaning to upload an article on this... __typeof() doesn't work on types that haven't been fully parsed by the compiler; this will be fixed in a future release. As a workaround, place a dummy class ahead of your MyControl class and specify it instead:
namespace NickHod
{
namespace Multimedia
{
private __gc class ThisAssembly
{
};\[ToolboxBitmapAttribute(\_\_typeof(ThisAssembly), S"CdDrive.bmp") \] public \_\_gc class CdDrive : public System::ComponentModel::Component {
The next trick is to name your bitmap using the fully qualifed namespace where the dummy-class lives. In my example above, the bitmap filename is "NickHod.Multimedia.CdDrive.bmp" In the Linker/Input settings for your project, specify this bitmap under "Embed Managed Resource File" (the linker switch is /ASSEMBLYRESOURCE). The other thing you'll need to do is use sn.exe to genereate a strong-name for your assembly (specified in AssemblyKeyFileAttribute() in AssemblyInfo.cpp), then register it in the GAC with gacutil.exe. Good luck! -Nick This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.