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

From EXE to OCX

Posted on 2000-02-15
Last Modified: 2013-11-20
I am using MSVC6.0 on Win NT 4.0 + SP5
for devlopment and Win 98 for testing.

IE 5.0 security settings are default.

I have source code for MFC applications that compiles to give executable files.
Now the boss needs the program to run from the browser page.
Is there any quick way to make the program compiles to OCX. Or is there a way to wrap the program into Java applet or ActiveX?
Question by:soso071898
  • 3
  • 2
  • 2
  • +2

Expert Comment

ID: 2527504
It all really depends on what kind of output the program has, and what kind of input (aka database access). You could theoretically create a blank ActiveX or OLE document project, and paste your code in.

Author Comment

ID: 2528205
Thanks a lot.
The program is a kind of interactive editor. GUI is a dialog that takes input from the user and creat a text file. The text file needs to be saved locally on HDD or uploaded to a server SQL DB.
The program can also read old text files from HDD or from SQL server DB.

If I create a balnk ActiveX, I have to modify all the classes and functions which I am trying to avoid. I do not know if it will be different with OLE document cause i have experience with ActiveX only. However, I will consider any solution/technology that enables me to minimze the required code changes.

Expert Comment

ID: 2536412
Check the following article to see if it helps you.  If all of your code is encapsulated within your dialog class, you could potentially use the approach explained in this article with very little pain (cutting and pasting the dialog resource and the class into a new MFC ActiveX project).

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.


Accepted Solution

cclain earned 200 total points
ID: 2542819
If your program is in a dialog box, you can do it:

-Create a new MFC ActiveX ControlWizard project with default option
(ex: NewApp.dsw)

-Copy your dialog ressource (IDD_OLDAPP)to the new project

-Add your dialog .cpp and .h files to the new project (OldAppDlg.cpp and OldAppDlg.h)

-Declare a COldAppDlg object in NewAppCtrl.h:
    COldAppDlg dlg;

-Override WM_CREATE message in NewAppCtrl class:
int CNewAppCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
  if (COleControl::OnCreate(lpCreateStruct) == -1)
    return -1;

  CRect rect;
  return 0;

-Compile and test
NewApp.ocx can be put in IE

Expert Comment

ID: 2547004

Expert Comment

ID: 2549495
you mean ?

Expert Comment

ID: 2549613
I just wanted to get an email notification on any action herein since I'm interested in this topic, too.
BTW, I cannot see a significant difference between mandhjo's link at codeguru and your posted code fragment...


Expert Comment

ID: 2550384
Actually, I had to do this in several projects. Moreover, there is a lot of answers in codeguru which speak about this subject and which helped me but no one was working perfectly.
For the WM_PAINT message for instance, I found this method was good if you have to use your activeX in IE and in Visual C++ editor:

void CNewAppCtrl::OnDraw(
                  CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
  if (IsWindow(dlg.m_hWnd))
    pdc->TextOut(10,30,"ActiveX NewAppCtrl");

Expert Comment

ID: 2551212
mitrakis:  Thanks for pointing that out.  By the way, you can click on 'Submit' without adding a comment and it will add you to the list of people who are notified when comments and answers are provided.  Just thought I'd let you know.

cclain:  You are right about the OnDraw method.  You must be certain that the dialog is created before attempting to call RedrawWindow...otherwise (as you have found out) an assertion will occur in DEBUG mode and the control will fault in release mode.

soso:  Have these suggestions helped?  Are you running into other difficulties?

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 154
repeatSeparator  java  challenge 13 58
C++ BOOL WINAPI ReadFile fails on windows 10 when reading from USB cable 9 473
unix example issues 18 99
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

837 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