Subclassing an ActiveX control

I know how to subclass a commmon windows control when creating an MFC ActiveX Control (just select from the list box).  But I would like to do the same type of thing with an existing ActiveX control, basically I want to take an existing ActiveX and and some additional functionality.  I am trying to meet a deadline, so if someone could just paste some quick and dirty instructions, and I'll worry about understanding what I did later.  Thanks,
LVL 2
willmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jhanceCommented:
ActiveX control are not like Windows controls.  ActiveX controls are managed by the COM subsystem in Windows.  It is possible to "subclass" them but the technique is very different than how you do it for common controls.  You need to make a new ActiveX control that with both contain your old control and expose a new interface that will "plug" into your existing application.  The containing control will thus be in the middle between your app and the old control.  Any messages that can be processed the old way can just be passed on to the old control.  Any extensions should be handled by your new control.  
0
willmanAuthor Commented:
I had assumed it would be "very different".  This seems a very vague and undetailed answer for a 220 point question.
0
jhanceCommented:
How familiar you are with ActiveX control development?  Do you know how to build a control or are you just familiar with using controls in your application?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

mikeblasCommented:
But, the problem is that you can't do "the same type of thing".  OLE Controls simply don't provide a mechanism to sublcass eachother.

The two things you can do are:

1) Write a new control that contains the other control. Then, it's up to you to expose whatever interface from your control that you want to expose.  You'll need to recreate the methods want to expose, and you can do whatever you'd like to them as they go by before you call the method on the control your containing. Same thing for events fired from the control you're containing. You'll have some funky focus and input problems, depending on how complicated the control you're containing is. The issues that you'll face are largely solved by the http://support.microsoft.com/support/kb/articles/q155/9/73.asp KB article--containing a dialog in an OLE control causes the same problems you'll face.

2) You can take a strictly OLE approach and aggregate on the control. That'll work, but MFC provides very little support for writing the aggregating control. (Any MFC control can be aggregated.) This approach can relieve the issues you'll face above, but is a much more difficult approach as you'll need to use ATL or COM directly to implement your aggregation wrapper.

None of these things is close to the "same type of thing" as subclassing. They're very, very different. "Just adding some functionality" might be trivial, if you're just going to add a few extra properties, fluff up a couple of methods into more functionality.

On the other hand, if you need to fire some extra events, you're probably going to face a very difficult road. If you're going to try to do some different or alternate rendering within the control, you're in big big trouble.

.B ekiM

0
willmanAuthor Commented:
Thanks Mikeblas,  I not familiar with aggregating--if you could give me some more info, I'd appreciate it.

to jhance: I have written a few small controls in VC++, and have written one in VB5 (Though VB hardly counts), so I have some experience in creating, but not alot.

The reason I am doing this "upgrading" of a control, Is that I am going to use it on a web page, but certain elements of the control can only be changed when it is created with the CWnd::Create or CWnd::CreateEx functions -- functions I obviously would not have access to in a web page, even with the best scripting language.  Although the control is fairly complicated, it looks as if mikeblas option #1 will be the most feasible.
0
mikeblasCommented:
The docs cover aggregation better than I can, here.  The bottom line is that you have two objects: one you write, and one you're containing.  You supply your own IUnknown implementation that provides pointers to interfaces that you implemnet yourself, _or_ to interfaces actually exposed by the object you're containing. It's up to you, and the decision of which interface to supply ends up being very similar to the way you decide which virtuals to override in regular C++.

.B ekiM
0
mikeblasCommented:
Do you need anything else?

.B ekiM

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
willmanAuthor Commented:
Thanks, aggregation was what I was looking for -- It's only slightly more difficult than inheriting a C++ class.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.