locked
VB6 and C# user control RRS feed

  • Question

  • Hi,

    In my application I have to make a user control in C# which will be used in vb6 forms. now there are couple of questions:

    1. How we can have the handle of vb6 main form. In C# if I write a code like mycontrol.parent, I am able to get the access the mail form, but when I will be using that conrol in vb6 it gives an exception like "Object reference not set"

    2. How we can change the icon of that component. Though I am able to change the icon within the .net, but this does not reflect in VB6.

    If anyone has used the user controls of C# sucessfully in VB6 , kindly help me out.
    Any help will be appriciated.
    Sunday, November 5, 2006 10:39 AM

Answers

  • You'll have a lot of trouble making this work, the VB6 ActiveX control hosting interface is radically different from the Windows.Forms model.  The .NET Parent property references a Control instance, a VB6 container is not a Control.  You'd probably need something like IOleObject::GetClientSite() to find the VB6 container but that's a long shot.

    Similarly, a .NET toolbox bitmap is a .NET resource, VB6 knows nothing about those kinds of resources.  A VB6 toolbox bitmap is a 16x15, 16 colors bitmap, stored as a native Windows bitmap resource in the DLL with resource identifier 30000 and up.  I don't know how the bitmap gets associated with the control...

    Good luck with this!
    Sunday, November 5, 2006 12:04 PM