Solved

Using ActiveX in non-MFC app

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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