?
Solved

Subclassing an ActiveX control

Posted on 1998-02-28
8
Medium Priority
?
521 Views
Last Modified: 2013-11-20
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,
0
Comment
Question by:willman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 1316659
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
 
LVL 2

Author Comment

by:willman
ID: 1316660
I had assumed it would be "very different".  This seems a very vague and undetailed answer for a 220 point question.
0
 
LVL 32

Expert Comment

by:jhance
ID: 1316661
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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 11

Expert Comment

by:mikeblas
ID: 1316662
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
 
LVL 2

Author Comment

by:willman
ID: 1316663
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
 
LVL 11

Expert Comment

by:mikeblas
ID: 1316664
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
 
LVL 11

Accepted Solution

by:
mikeblas earned 880 total points
ID: 1316665
Do you need anything else?

.B ekiM

0
 
LVL 2

Author Comment

by:willman
ID: 1316666
Thanks, aggregation was what I was looking for -- It's only slightly more difficult than inheriting a C++ class.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question