Reputation: 4609
For ActiveX development what should I use? MFC or ATL?
In Microsoft Documents it says we can use MFC to build ActiveX controls. But when I was googling I saw some people mentioning that ATL is good for the job. This is what i got from Wikipedia which seems like confirming that argument.
ATL, on the other hand, is a more lightweight alternative in situations where the graphical user interface parts of MFC are not required.
What should I use? If I can use both, what are the pros and cons of using them?
Upvotes: 3
Views: 827
Reputation: 6040
Use ATL. I have been developing in MFC for 20+ years. For the vast majority of uses, ATL is the better choice because it is more lightweight and simpler to understand--although both have a steep learning curve.
The only reason I would choose MFC over ATL for usage would be:
1) I have a very involved ActiveX/windows control I'm writing and it makes sense to write the windows control part of it in MFC and therefore it makes sense to piggyback the COM interface of the control in MFC. However, for supplemental objects (say a property that returns an Object), I would use ATL unless they too were a very involved windows control.
2) I have to use OLE (object linking and embedding) for a document type and it is easier to use MFC's built in framework for that.
I have been working on the same MFC project for 20+ years, a very involved Windows program. Most aspects of the program are exposed by COM. We have a mixture of MFC COM and ATL COM. When I first started out, and before ATL had gained traction, I usually implemented the COM objects in MFC. Now, unless something fits the above two reasons, I use ATL.
But, it's just an opinion.
Upvotes: 6
Reputation: 15375
ATL is here my No. 1!
It is much more flexible in designing the interface and how the COM object handling is extremely adjustable.
ATL also allows easy construction of dual interfaces. MFC hast just a straight forward IDispatch implementation.
Even in my MFC application I use internally only ATL for all COM parts.
Upvotes: 4
Reputation: 42984
While it's possible to build ActiveX components using MFC, ATL was designed as a lightweight and more efficient lower-overhead alternative. Moreover, you can also use WTL on top of ATL for the GUI part.
I would suggest using ATL (and WTL) if you want a smaller low-overhead ActiveX component.
Upvotes: 4