Solved

Using ActiveX in non-MFC app

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 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