ActiveX Control's Bitmaps in ToolBox
-
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...
-
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...
Last time I checked, I could not find one. I used the registry to extract that information. Good music: In my rosary[^]
-
Last time I checked, I could not find one. I used the registry to extract that information. Good music: In my rosary[^]
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.
-
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.
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[^]
-
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[^]
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
-
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
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[^]
-
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[^]
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?