Solved

Using ActiveX in non-MFC app

Posted on 1997-11-15
2
648 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 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