COleControl and CWnd - Using both - Newbie
  Home FAQ Contact Sign in
microsoft.public.vc.mfc only
 
Advanced search
POPULAR GROUPS

more...

microsoft.public.vc.mfc Profile…
 Up
COleControl and CWnd - Using both - Newbie         


Author: Nobody
Date: Aug 25, 2007 15:03

Hi,

Now that I can make custom controls,
http://www.codeproject.com/miscctrl/customcontrol.asp
I would like to move to the next step.

So, I guess I would like to turn my control into a COM / ActiveX control to use with VB/C# and ASP web pages.
And just to get some experience with COM / ActiveX.

I noticed something on one ActiveX control that I stumbled upon.
It is not inheriting from CWnd. It inherits from COleControl
COleControl inherits from CWnd. (That is good)

Now, I am wondering what all that entails.

"In a windowless control, you should always use the COleControl member functions instead of the
corresponding CWnd member functions or their related Windows API functions."
I suppose what they mean by this, is that an ActiveX control is a Windowless control and I have to use COleControl member functions.
That sounds reasonable...

Well, some of the methods are not the same.
virtual void COleControl::OnDraw(CDC* pDC, const CRect& rcBounds, const CRect& rcInvalid );
differs from CWnd::OnDraw(CDC* pDC);
Show full article (2.92Kb)
9 Comments
Re: COleControl and CWnd - Using both - Newbie         


Author: Ajay Kalra
Date: Aug 25, 2007 23:55

On Aug 25, 9:03 am, "Nobody" yahoo.com> wrote:
> Hi,
>
> Now that I can make custom controls,http://www.codeproject.com/miscctrl/customcontrol.asp
> I would like to move to the next step.
>
> So, I guess I would like to turn my control into a COM / ActiveX control to use with VB/C# and ASP web pages.
> And just to get some experience with COM / ActiveX.
>
> I noticed something on one ActiveX control that I stumbled upon.
> It is not inheriting from CWnd. It inherits from COleControl
> COleControl inherits from CWnd. (That is good)
>
> Now, I am wondering what all that entails.
>
> "In a windowless control, you should always use the COleControl member functions instead of the
> corresponding CWnd member functions or their related Windows API functions."
> I suppose what they mean by this, is that an ActiveX control is a Windowless control and I have to use COleControl member functions.
> That sounds reasonable...
> ...
Show full article (3.28Kb)
no comments
Re: COleControl and CWnd - Using both - Newbie         


Author: David Ching
Date: Aug 26, 2007 06:27

"Ajay Kalra" yahoo.com> wrote in message
news:1188078902.389301.278000@22g2000hsm.googlegroups.com...
> Nothing specfic about your issue but you should not be using MFC to
> develop activex controls which are deployed over the web. ATL is
> significantly better as its lightweight.
>

Frankly a 300 KB ActiveX control written in MFC is no big deal anymore?

-- David
no comments
Re: COleControl and CWnd - Using both - Newbie         


Author: Nobody
Date: Aug 26, 2007 10:19

Hi,
> Nothing specfic about your issue but you should not be using MFC to
> develop activex controls which are deployed over the web. ATL is
> significantly better as its lightweight.

Yeah, I just read about ATL and WTL.
I am just trying to start off by learning COM / ActiveX.
I am not yet that proficient to use ATL.
I have no experience with STL, ATL or WTL.

These are the just the links I stumbled upon.

ATL and COM
http://www.codeproject.com/atl/com_atl.asp

WTL 8 part series.
http://www.codeproject.com/wtl/wtl4mfc1.asp

This is a really cool articlel about Virtual tables.
This has got, the most bizzarest code I have ever seen!
(Besides the "c" obfuscation contest.)
pFun = (Fun)*((int*)*(int*)((int*)&objDrive+0)+0);
http://www.codeproject.com/atl/atl_underthehood_.asp

Thanks,
"Ajay Kalra" yahoo.com> wrote in message news:1188078902.389301.278000@22g2000hsm.googlegroups.com...
> On Aug 25, 9:03 am, "Nobody" yahoo.com> wrote:
>> Hi,
>>
>> Now that I...
Show full article (4.28Kb)
no comments
Re: COleControl and CWnd - Using both - Newbie         


Author: Giovanni Dicanio
Date: Aug 26, 2007 11:57

"Ajay Kalra" yahoo.com> ha scritto nel messaggio
news:1188078902.389301.278000@22g2000hsm.googlegroups.com...
> Nothing specfic about your issue but you should not be using MFC to
> develop activex controls which are deployed over the web. ATL is
> significantly better as its lightweight.

IMHO, ATL (and WTL) is more complex than MFC. One can be a good C++
programmer and use MFC proficiently; OTOH, ATL and WTL are heavily based on
templates, and other C++ advanced tricks. And the error messages with
templates are more obscure, too.
Of course, ATL offers more control for COM development than MFC offers. But,
if this ATL power is not required, I think that MFC would be just fine for
ActiveX development.
And I think that the "lightweight" argument about ATL vs MFC is now
obsolete. It could be a good argument when people had 56kbps modems... but
now with fast ADSL lines the lightweight argument is no more, IMHO.

Giovanni
no comments
Re: COleControl and CWnd - Using both - Newbie         


Author: Ajay Kalra
Date: Aug 26, 2007 14:10

> IMHO, ATL (and WTL) is more complex than MFC. One can be a good C++
> programmer and use MFC proficiently; OTOH, ATL and WTL are heavily based on
> templates, and other C++ advanced tricks. And the error messages with
> templates are more obscure, too.

That is probably true for most of us but there is no way for us to
judge OPs skills in this area. Besides the right answer is still not
to use MFC for this unless you have a reason for it. ATL was developed
for this purpose only and it continues to be leader in this area.

---
Ajay
no comments
Re: COleControl and CWnd - Using both - Newbie         


Author: Ajay Kalra
Date: Aug 26, 2007 14:13

On Aug 26, 12:27 am, "David Ching" remove-this.dcsoft.com>
wrote:
> "Ajay Kalra" yahoo.com> wrote in message
>
> news:1188078902.389301.278000@22g2000hsm.googlegroups.com...
>
>> Nothing specfic about your issue but you should not be using MFC to
>> develop activex controls which are deployed over the web. ATL is
>> significantly better as its lightweight.
>
> Frankly a 300 KB ActiveX control written in MFC is no big deal anymore?
>
> -- David

MFC has significant shortcomings as to what it offers to develop COM
components compared to ATL. It stops well short of what a COM
component can deliver. I still kind of disagree with lightweight
argument though. Also IIRC,, MFC is almost 1MB in release build and
its not only the download speed; IE would be loading these components
as well.
Show full article (0.83Kb)
no comments
Re: COleControl and CWnd - Using both - Newbie         


Author: David Ching
Date: Aug 26, 2007 14:45

"Ajay Kalra" yahoo.com> wrote in message
news:1188130417.012890.27120@w3g2000hsg.googlegroups.com...
> MFC has significant shortcomings as to what it offers to develop COM
> components compared to ATL. It stops well short of what a COM
> component can deliver.

I agree. But the main disadvantage of MFC that I remember is it only uses
IDispatch and not dual interface. Maybe that doesn't matter.
> I still kind of disagree with lightweight
> argument though. Also IIRC,, MFC is almost 1MB in release build and
> its not only the download speed; IE would be loading these components
> as well.
>

1 MB? You can develop an ActiveX control in like 150 KB, statically linked
of course!

-- David
no comments
Re: COleControl and CWnd - Using both - Newbie         


Author: Giovanni Dicanio
Date: Aug 26, 2007 16:41

"Ajay Kalra" yahoo.com> ha scritto nel messaggio
news:1188130202.623660.42050@y42g2000hsy.googlegroups.com...
>> IMHO, ATL (and WTL) is more complex than MFC. One can be a good C++
>> programmer and use MFC proficiently; OTOH, ATL and WTL are heavily based
>> on
>> templates, and other C++ advanced tricks. And the error messages with
>> templates are more obscure, too.
>
> That is probably true for most of us but there is no way for us to
> judge OPs skills in this area.

You are correct.
> Besides the right answer is still not
> to use MFC for this unless you have a reason for it. ATL was developed
> for this purpose only and it continues to be leader in this area.

If the OP can master ATL, I agree with you: ATL is the leader tool for COM
development.

Giovanni
no comments
Re: COleControl and CWnd - Using both - Newbie         


Author: Ajay Kalra
Date: Aug 26, 2007 16:46

> statically linked of course!

:-)

---
Ajay
no comments