Create an MFC OCX using C++ DLL
Hello Guru's
Im am a newbie here trying to create a OCX from a C++ dll., Here's the scenario
I have a C++ dll and this dll needs to be called in VB.net program my boss want's me to create an OCX out of this
C++ dll and use it in a VB.net class library, apparently I have created an OCX but it requires a form but the VB.net program is a class library.
Any one there can help me here.,
Regards,
Newbie here
Re: Create an MFC OCX using C++ DLL
OCX you mention here is just an alias to ActiveX term, which in its turn is an alias to COM in-proc server. So let's talk a bit about COM in-proc servers.
COM is Windows way to bring OOP to languages including ones not supporting OOP natively, and provide cross-language use of components doing that some standard way. In COM world server exposes a number of coclasses, each of ones exposes a number of interfaces where each one exposes a number of methods and properties. Internally those may be implemented in any language that is able to build native Windows DLLs.
From C++ perspective COM DLL is a regular C/C++ DLL that follows COM programming guidelines. Internally it makes use of C++ classes and exposes their member functions and data via COM methods and properties respectively, but transposing internally used C++ data types to COM data types. Additionally it takes care of internal C++ object life cycles to comply with COM object life cycles.
There is one more point here you are to take into consideration. COM DLL may implement dual DLL interface, including both COM specific and usual C++ exports, or may implement only COM and link to external C++ DLL making use of the latter. Remember that COM DLL is just a regular DLL with some standard exports, so it is allowed do all the things that any regular DLL does.
In case you have no idea about COM programming, I have bad news for you: it's not something trivial, and you have to gain some experience first. Exposing COM to .NET is another knowledge you are to gain.
Re: Create an MFC OCX using C++ DLL
Hello Igor:
Thanks for the clear distinction of the COM interface, YES you are right I don't have enough knowledge about the COM,.. Any link for the tutorial would help me gain knowledge.
As I mentioned my goal is to create an ActiveX(.OCX) or a COM interface coming from the C++ dll.
If you someone can give me some trick how to do it and I would gladly appreciate it.
Regards,
Newbie here
Re: Create an MFC OCX using C++ DLL
If you want to do this in 32-bit, I suggest you create a ActiveX control rather than the older OCX control.
As Igor mentioned, programming in COM isn't trivial, but in my opinion a good way to get up to speed with a usable control is to use ATL.
A good book (albeit a bit dated) is: Beginning ATL 3COM Programming
Re: Create an MFC OCX using C++ DLL
Quote:
Originally Posted by
Arjay
If you want to do this in 32-bit, I suggest you create a ActiveX control rather than the older OCX control.
As Igor mentioned, programming in COM isn't trivial, but in my opinion a good way to get up to speed with a usable control is to use ATL.
A good book (albeit a bit dated) is:
Beginning ATL 3COM Programming
You might also want to have a look at MS Inside ATL
http://www.amazon.co.uk/Inside-ATL-P...tl+programming
There are several books that cover ATL/COM/ActiveX etc. I would suggest that you do a search on Amazon and consider the content and the reviews to choose one suitable for your requirements. Some are quite dated (from 1998/1999/2000) but their content is still relevant.
Re: Create an MFC OCX using C++ DLL
Quote:
Originally Posted by
kpax1684
YES you are right I don't have enough knowledge about the COM,.. Any link for the tutorial would help me gain knowledge.
I don't think I could recommend anything better than what plain google search would do. I believe, MSDN, and CodeGuru, and CodeProject sites are good to start with.