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. COM
  4. ActiveX Control's Bitmaps in ToolBox

ActiveX Control's Bitmaps in ToolBox

Scheduled Pinned Locked Moved COM
comjsontutorial
7 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    Ashwin kumar Gurujala
    wrote on last edited by
    #1

    Hi, I want to know whether there is any API to show Bitmaps of Registered ActiveX Controls in a ToolBox. If not , any idea on how to go about...

    J 1 Reply Last reply
    0
    • A Ashwin kumar Gurujala

      Hi, I want to know whether there is any API to show Bitmaps of Registered ActiveX Controls in a ToolBox. If not , any idea on how to go about...

      J Offline
      J Offline
      Jorgen Sigvardsson
      wrote on last edited by
      #2

      Last time I checked, I could not find one. I used the registry to extract that information. Good music: In my rosary[^]

      A 1 Reply Last reply
      0
      • J Jorgen Sigvardsson

        Last time I checked, I could not find one. I used the registry to extract that information. Good music: In my rosary[^]

        A Offline
        A Offline
        Ashwin kumar Gurujala
        wrote on last edited by
        #3

        can you just code it in brief on how to show bitmaps from registry. This is useful to me since i have no idea on how to do it.

        J 1 Reply Last reply
        0
        • A Ashwin kumar Gurujala

          can you just code it in brief on how to show bitmaps from registry. This is useful to me since i have no idea on how to do it.

          J Offline
          J Offline
          Jorgen Sigvardsson
          wrote on last edited by
          #4

          The components registry "folder" is located in HKEY_CLASSES_ROOT\CLSID\{<clsid here>}. Under that key is the ToolboxBitmap32 key. The default value of that key is the toolbox bitmap. The string value is on the form module,id. Parse the module and id into their own variables. Then open the module using LoadLibraryEx(), using the LOAD_LIBRARY_AS_DATAFILE option. Then use the function LoadBitmap with the handle returned from LoadLibraryEx(), and the id "transformed" with MAKEINTRESOURCE(). Pseudo-code:

          LPCTSTR lpszToolboxBitmap32 = GetToolboxBitmap32ForCLSID(clsidOfComponent);
          LPCTSTR lpszModule;
          int nId;
          ParseBitmapString(lpszToolboxBitmap32, &lpszModule, &nId);

          HMODULE hLibrary = ::LoadLibraryEx(lpszModule, NULL, LOAD_LIBRARY_AS_DATAFILE);
          HBITMAP hBmp = ::LoadBitmap(hLibrary, MAKEINTRESOURCE(nId));
          ::FreeLibrary(hLibrary);

          // the handle to your bitmap is now in hBmp

          I hope this helps. Good music: In my rosary[^]

          A 1 Reply Last reply
          0
          • J Jorgen Sigvardsson

            The components registry "folder" is located in HKEY_CLASSES_ROOT\CLSID\{<clsid here>}. Under that key is the ToolboxBitmap32 key. The default value of that key is the toolbox bitmap. The string value is on the form module,id. Parse the module and id into their own variables. Then open the module using LoadLibraryEx(), using the LOAD_LIBRARY_AS_DATAFILE option. Then use the function LoadBitmap with the handle returned from LoadLibraryEx(), and the id "transformed" with MAKEINTRESOURCE(). Pseudo-code:

            LPCTSTR lpszToolboxBitmap32 = GetToolboxBitmap32ForCLSID(clsidOfComponent);
            LPCTSTR lpszModule;
            int nId;
            ParseBitmapString(lpszToolboxBitmap32, &lpszModule, &nId);

            HMODULE hLibrary = ::LoadLibraryEx(lpszModule, NULL, LOAD_LIBRARY_AS_DATAFILE);
            HBITMAP hBmp = ::LoadBitmap(hLibrary, MAKEINTRESOURCE(nId));
            ::FreeLibrary(hLibrary);

            // the handle to your bitmap is now in hBmp

            I hope this helps. Good music: In my rosary[^]

            A Offline
            A Offline
            Ashwin kumar Gurujala
            wrote on last edited by
            #5

            Thanks for the Solution, One problem how can i pass handle of bitmap to object of CBitmap.... or is there any other way of using it.... HBITMAP hBmp; hBmp = ::LoadBitmap( hLibrary, MAKEINTRESOURCE(nID) ); //! Here LoadBitmap Accepts HICON & CBitmap*...but not HBITMAP..So how can I pass HBITMAP to CImageList so that it can be attached to CToolBar CBitmap obBitmap; obBitmap.LoadBitmap( hBmp ); //error...how to pass hBmp CImageList obImageList; obImageList.Create(18,18,ILC_COLOR8,2,1); obImageList.Add( &obBitmap , RGB(0,0,0)); CToolBar obToolBar; obToolBar.GetToolBarCtrl().SetImageList(&obImageList); -- modified at 7:43 Thursday 1st September, 2005

            J 1 Reply Last reply
            0
            • A Ashwin kumar Gurujala

              Thanks for the Solution, One problem how can i pass handle of bitmap to object of CBitmap.... or is there any other way of using it.... HBITMAP hBmp; hBmp = ::LoadBitmap( hLibrary, MAKEINTRESOURCE(nID) ); //! Here LoadBitmap Accepts HICON & CBitmap*...but not HBITMAP..So how can I pass HBITMAP to CImageList so that it can be attached to CToolBar CBitmap obBitmap; obBitmap.LoadBitmap( hBmp ); //error...how to pass hBmp CImageList obImageList; obImageList.Create(18,18,ILC_COLOR8,2,1); obImageList.Add( &obBitmap , RGB(0,0,0)); CToolBar obToolBar; obToolBar.GetToolBarCtrl().SetImageList(&obImageList); -- modified at 7:43 Thursday 1st September, 2005

              J Offline
              J Offline
              Jorgen Sigvardsson
              wrote on last edited by
              #6

              CBitmap is just a C++ wrapper for HBITMAP. Use CBitmap::FromHandle() to acquire a CBitmap object. It returns a CBitmap*, but you don't have to free it. The returned pointer is a pointer to a temporary object, which is removed next time the window pump is idling. So in short, use the pointer on the same call stack as you acquired it. Please see the MSDN docs for a more comprehensive explanation. :) Good music: In my rosary[^]

              A 1 Reply Last reply
              0
              • J Jorgen Sigvardsson

                CBitmap is just a C++ wrapper for HBITMAP. Use CBitmap::FromHandle() to acquire a CBitmap object. It returns a CBitmap*, but you don't have to free it. The returned pointer is a pointer to a temporary object, which is removed next time the window pump is idling. So in short, use the pointer on the same call stack as you acquired it. Please see the MSDN docs for a more comprehensive explanation. :) Good music: In my rosary[^]

                A Offline
                A Offline
                Ashwin kumar Gurujala
                wrote on last edited by
                #7

                Thanks for the reply .... it worked out.. Now the major task for me after showing bitmaps of controls on toolbox is enabling drag 'n' drop facility of controls onto the container. I think IDesignerToolBoxSite interface is used for this. But how to use this interface in my application is what is troubling me? :(( Can u help me in this regard?

                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