Visual Basic Development Bookmark and Share   
 Home > Visual Basic Interop and Upgrade > Toolbox Icon for Interop User Control
 

Toolbox Icon for Interop User Control

I can't set the icon of the user control for the toolbox in vb6.

I followed the tutorial that is found here: http://www.codeproject.com/KB/vb-interop/VB6InteropToolkit2.aspx

I've been doing this for weeks already trying to figure out how can I do this. I am using VB .NET 2008

Please help..
Joseph Pedrero  Thursday, November 26, 2009 11:34 AM
Hi Joesph,

I didn't customize the icon of Interop usercontrol in VB6 Toolbox, but I check ActiveXControlHelpers.VB file and find out:

'ToolBoxBitmap32
Using bitmapKey As RegistryKey = subkey.CreateSubKey("ToolBoxBitmap32")

'If you want to have different icons for each control in this assembly
'you can modify this section to specify a different icon each time.
'Each specified icon must be embedded as a win32resource in the
'assembly; the default one is at index 101, but you can additional ones.
bitmapKey.SetValue("", Assembly.GetExecutingAssembly.Location & ", 101", _
RegistryValueKind.String)
End Using

You need to modify this value to implement your requirement for customizing icon in VB6 ToolBox. Please try it and feel free to post back for further discussion.


Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Monday, November 30, 2009 6:05 AM
Hi Riquel,

Thanks for the reply. I already tried that.. Unfortunately, it didn't work out well. That was also what the tutorials says over the net. Can there still be an another way to do it? Thanks
Joseph Pedrero  Tuesday, December 01, 2009 1:43 AM
Hi Joesph,

The ToolBox bitmap resource is specified in the regsitry key:
HKCR\CLSID\{CLSID of the control}\ToolBoxBitmap32\
(see the RegisterControl method in ActiveXCtrlHelper)
ToolBoxBitmap32 is used to identify the module name and the resource ID for a
16 x 16 bitmap as the toolbar button face. Each specified icon must be
embedded as a win32 resource in the assembly. In order to embed the bitmap
CSActiveX.bmp into the assembly as a win32 resource, we need to

Step1. Place the CSActiveX.bmp file in the root folder of the project.

Step2. Add a .rc file (CSActiveX.rc) to the project with the content:

101 BITMAP CSActiveX.bmp

101 is the resource ID, BITMAP is the resource type, and CSActiveX.bmp is the
resource name.

You can use classID to search in Registry to see this registry value in ToolBoxBitmap32 at the registry. When I change the value in registry with one existing icon file, it is changed in ToolBox in VB6( although it is not my expected result, it is one whole black plank). Based on this result, changing the embedded resource is one method to implement your requirement.


Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  Tuesday, December 01, 2009 5:39 AM
Hi Riquel,

Thanks for the reply... What do you mean by CSActiveX??
Joseph Pedrero  4 hours 58 minutes ago
It is one ActiveX control sample created by C# in this project. Actually it is equivalent to VB.NET interop usercontrol:
http://cfx.codeplex.com/
Best regards,
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
Riquel_Dong  26 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• dllregisterserver entry point was not found help
• OleDb exception in .NET Form
• Variable starts with underscore
• Repeat calling VB6 components from VB.NET with problems
• Open .Net 2.0 project in VS 2008
• Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
• The line has to have the inverted color of the background so it is visible.
• Loading large number of Graphical Objects on a Form
• COM+ DLL's mixed with .NET DLL's problems
• VB6 XP-Style-Manifest and Interop Forms Toolkit 2.0 will not work...