Activex Controls

I want to know the difference between creating a control through ATLComAppWizard and MFCActivexControl wizard.To my knowledge the later uses MFC and ATL won't use MFC.

More info??
Thanx
anilkumarvAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Answers2000Connect With a Mentor Commented:
MFC is a big _fat_ library with lots of functionality.  When you use MFC a big DLL is required to run your control, (or you can link the MFC library statically).  Adding about 1Mb to the download size.  However using MFC makes it much easier to add other Windows functionality (e.g. dialog boxes, graphics, ODBC data access, etc) to your control.

ATL is a small library without much functionality, except for writing OCX.  Basically with an ATL control you have to write all the Windows functionality from scratch using SDK style code (hard work).  The advantage is that your control is small to download.  However remember if you control includes lots of Windows functionality, you basically end up writing your own mini-MFC-like  framework - so don't underestimate (a) the amount of extra of work that may be involved for writing with ATL - also overestimate (b) the reduction in control size - for large sophisticated controls - this may be less than you think - because extra code is required from you.  

Another advantage for using ATL, is that if your control is usually quicker to instantiate (MFC doesn't have to be loaded into memory).  If you invoke the same control a million times in quick succession, using ATL.

Some people also think the ATL wrapper round COM is nicer than MFC's.  Personally I think there's not much in it.  Because of this, it's actually possible to write an ATL control, that uses MFC too.  This ofcourse negates any reduction in size advantage (because the big fat MFC libraries are still required).

Finally MFC can also be used to write full Windows apps.  ATL does not have any support for that.

One other

So in summary

MFC Controls
--------------------
For :
Easy to write (large supporting framework)
Easy to migrate existing MFC apps
Easy to share code with existing MFC apps

Against:
Large download size (requires MFC statically linked, or MFC DLLs)
Slow to invoke (MFC must be loaded)

Use if
(a) You have an existing MFC app/code you want to convert to a control
(b) You know MFC
(c) You care more about development time, than download time


ATL
--------
For:
Small downloads
Quick to invoke

Against:
Harder to write (you must call SDK/API style functions to do work)

Use if
(a) You care less about development time, than download time


ATL + MFC
-----------------
For :
Easy to write (large supporting framework)
Easy to migrate existing MFC apps
Easy to share code with existing MFC apps

Against:
Large download size (requires MFC statically linked, or MFC DLLs)
Slow to invoke (MFC must be loaded)

Use if
(a) Migrating/Transitioning MFC code to ATL
(b) You like ATL's wrapper on COM better than MFC


One last point, if you control is only ever gonna be hosted by an MFC app, you should consider putting C++ classes into an MFC extension DLL, and forget using a control.  The advantage for this is speed, performance and ease of development.  The disadvantage is it is difficult for third parties to interface to your control (they are highly vulnerable to version changes).

0
 
anilkumarvAuthor Commented:
Thanx,
0
All Courses

From novice to tech pro — start learning today.