Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a MFC ActiveX VC++ project that create a control to use in some VC# .NET projects.Why I didn't use .NET user control to develop this control because GDI is faster than GDI+ in drawing what I want this control shows.The control works well when it connects to database.Now I want it can accept a .NET DataSet as its datasource.For example if I use this ActiveX control in my .NET project,and I put it in a Form in VC# project,for example I want to have something like this in Form constructor:

C#
public MyForm()
{
       InitializeComponent();
       
       //What I want to achieve
       DataSet dsSource=new DataSet();
       //Populate dsSource somehow
       MyActiveX.DataSource=dsSource;
}

or maybe I can't have this type of properties in unmanaged code(I don't know yet) so I have to implement it in a member function in MFC ActiveX Control.
C#
public MyForm()
{
       InitializeComponent();
       
       //What I want to achieve
       DataSet dsSource=new DataSet();
       MyActiveX.SetDataSource(dsSource);
}

Is there anyway to pass a DataSet (or any other .NET class instance) to an ActiveX control and use it inside unmanaged code?how a .NET class can be used in VC++ unmanaged code?

Thanks for any guide line or reference.
Posted
Updated 26-Feb-14 20:42pm
v2

1 solution

You would 'generally' (because there's always an exception') use COM Interop

iirc there's a tool called tlbimp that generates a 'wrapper' for you - see if this helps :-

http://examples.oreilly.com/9780596527570/COMIntegrationC%23Nutshell2ndEd.pdf[^]

If that's no use, do a search for C#, COM, Interop, TLBIMP

I had a whole guide on this many years ago, but cant find it now :-(

[edit] - actually, relooking at your question, I don't think Ive answered it - I originally thought you were using a COM/ActiveX object in C# .NET - sorry [/edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900