Solved

Using ActiveX in non-MFC app

Posted on 1997-11-15
2
655 Views
Last Modified: 2013-12-04
I have a windows application developed in C++ (not using MFC).  I have been charged with adding various functionality to this application.  Many of the things I need to add are things that have already been developed as ActiveX or OLE controls.  I have found documentation about how to add ActiveX container support manually to an MFC-based application, but that obviously does me no good.  Can anyone help me or point me to online help on including ActiveX support in a NON-MFC windows application?
0
Comment
Question by:willman
2 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1408381
You have two choices in terms of books: Inside ActiveX Controls and Inside OLE are the best books I've seen that covers ActiveX and OLE stuff without MFC.

But ultimately, it is a matter of knowing the interfaces and supporting those interfaces. You can also check out the OLE programming reference manuals.
0
 
LVL 1

Accepted Solution

by:
shrif earned 150 total points
ID: 1408382
Here are your options.  You can purchase a toolkit to do this for you from Integroup at http://www.intergrouptech.com/prodinfo.html.  They are fairly expensive, but the toolkit does exactly what you need -- provide ActiveX containment to a non-MFC application.  They'll also give you a good idea as to the complexity of such a project.
The next option is to write it yourself.  You should get a copy of "Inside ActiveX Controls", "Inside COM" and "ActiveX Web Controls".  Then get the ActiveX SDK and look up under containment.  This document will tell you which interfaces you need to support.  Basically, an ActiveX control is an OLE compound-document that's in process and is embedded and supports properies using Automation and source methods called events.  So you should start with creating an regulard OLE container (one that can contain Excel, for instance), as that is better documented.  You can use "Inside OLE" for this.  OLE Controls (aka OCX's or ActiveX controls) have additional interfaces that you need to support such as handling events and notifications.
For further reading on the subject see the following sites:
See "How to write an OCX container " at
    http://www.neca.com/~vmis/
Also, "OLE Control Containers" at
    http://www.wrox.com/wrox/books/923.htm.
The MSDN has an article and sample called CPATRON, which is a modified version of the PATRON client application from "Inside OLE".

Honesly, though, this is a huge task.  I don't recommend that you do this in plain C.  If you are not going to use the Intergroup stuff mentioned above, then you should use MFC.  Don't think that just because your current application is not MFC, that you can't use MFC with it.  I had the same situation where I had a C++ Win32 application to which I needed to add ActiveX Control containment support.  I simply added MFC to the project and only used MFC in those few source files.  
You just create a global variable of type CWinApp, as in:
CWinApp      theApp;
and then call AfxWinInit() from your WinMain.  That's all there is to using MFC from a non-MFC application.  In addition, you should call       AfxEnableControlContainer();
from WinMain to enable ActiveX control containment.

You can use Class-Wizard to wrap existing controls with C++ classes as is, or you can drag and drop the ActiveX controls on CDialog's or CFormView's.

Good luck
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now