COM control passed to .NET

K

Kalvin

I have a C# class which is created by a VB6 application. In the VB6 a
VBControlExtender is created and passed to the C# class. In VB6 you
get to the underlying control of a VBControlExtender by
calling .object on the VBControlExtender. How do get to the
underlying control once this VBControlExtender is passed to C#. I
can't cast the passed control to AxHost, or any other type of .NET
control, because it isn't a .NET control. I can't access the
underlying object of the VBControlExtender without casting to
something besides object, but I don't know what to cast it to. Please
help.
 
P

Patrice

Hi

What is the type of this control ?

For now I'm not sure what you do as :
- "I have a C# class which is created by a VB6 application" note sure what
you mean (my understanding would be that you create a .NET object (exposed
to com) using VB 6)
- " it isn't a .NET control" seems a bit contradictory...

If this is not a .NET control have you tried to reference the type libary
for this control to create the wrapper that will make it availble inside
..NET...



"Kalvin" <[email protected]> a écrit dans le message de groupe de
discussion :
(e-mail address removed)...
 
K

Kalvin

Thanks for the reply.
The control is created in VB6 by ProgID:
-- Begin Code Snip
Private WithEvents myControl As VBControlExtender

Public Sub CreateControl(progID As String)
Set myControl = Controls.Add("progID", "inputControl", Me)
End Sub
-- End Code Snip

Then myControl is passed to a different C# component. The problem I
am having is that myControl is a VBControlExtender, and C# doesn't
know what that is? In VB6 I would get at the actual control created
the call to Controls.Add by using myControl.object. This isn't
available in C# to get the actual object created.
 
P

Patrice

I gave this a try and it seems VBControlExtender is defined in VB6.OLB which
doesn't seem to import fine in .NET...

IMO it should be much easier to expose your own interface to C# rather than
to expose those low level classes. Then you could :
- use this interface on the C# side
- have a wrapper on the VB side to expose whatever control you need to C#

And you have full control about what is exposed... On the C# side you'll
likely have to use reflection (do you intend to work with a known progid or
should you be able to accomodate several ones ?)

Also knowing what is your ultimate goal could also be helpfull. In
particular it looks like a bit unusual to share such low level classes
accross both those words and I suspect you would come in some other
problem... Do you try something such as acting on a VB6 UI directly from a
C# code ? IMO it would be best to have something in between rather than
doing this directly.

For now, my personal preference would be likely to start with sample code as
defined in #1 and progress from there rather than trying to use directly the
VBControlExtender...

--
Patrice


"Kalvin" <[email protected]> a écrit dans le message de groupe de
discussion :
(e-mail address removed)...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top