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).
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.


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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 93
How to determine file rename from EventLog ? 2 49
sumDigits challenge 9 153
wordmultiple challenge 12 136
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

803 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