Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. ToolBoxBitMap Attribute

ToolBoxBitMap Attribute

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++graphicshelptutorial
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Firoz
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • F 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

      N Offline
      N Offline
      Nick Hodapp
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups