Link to home
Start Free TrialLog in
Avatar of JohnnyKnoxville
JohnnyKnoxville

asked on

Passing Data from C# to VB6 Active X control (and vice versa)

I have an active X control written in VB6.  I am creating a C# project and need to pass data back and forth to the active x control.    Cant I just add the VB6 control to C# project reference and then be able to see public methods and send data over?   Is this possible?  What packages are needed to do this? COM.Interop?

Please help as soon as possible.

thx,

Knoxxx
ASKER CERTIFIED SOLUTION
Avatar of ShazbotOK
ShazbotOK
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JohnnyKnoxville
JohnnyKnoxville

ASKER

The Active X control  must be registered with a 3rd party app.  This creates somewhat of a built in panel in the 3rd party app.  When the 3rd party app loads, it loads my active X control.  Now...if I have a .NET project and need to grab the handle of this active x control....how is this accomplished?

If I simply use..

MyActiveXControl myCtrl = new MyActiveXControl();

This will give me a new instance.  What I need is the existing handle to the instance when it loaded in the 3rd party app.  I need to be able to populate data into the VB6 controls (text box , combobox, etc)

I tried to create a handle to the user control using CopyMemory  and expose it in a public class.  

Now I try this in C#...

MyActiveXControl.clsEventManagement myCtrl = new MyActiveXControl.clsEventManagement();
myCtrl.PassDataToTextBox("Some String");

This throws an error:

Retrieving the COM class Factory for component with CLSID -{21301F0D-E249-4906-9D85-87D9DE8559EF  Failed due to the following reason 80040154

Im completely stuck.  Im beginning to think its not possible to pass data back and forth because I cant get the original handle.  Is there a way to get a list of active window handles and look for my active x control?  Then try to grab it that way?