Solved

From EXE to OCX

Posted on 2000-02-15
9
258 Views
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?
0
Comment
Question by:soso071898
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 2

Expert Comment

by:Gandalf32
Comment Utility
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.
0
 

Author Comment

by:soso071898
Comment Utility
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.
0
 
LVL 4

Expert Comment

by:mandhjo
Comment Utility
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).

http://www.codeguru.com/atl/dialogctrl.shtml
0
 

Accepted Solution

by:
cclain earned 200 total points
Comment Utility
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:
  public:
    COldAppDlg dlg;

-Override WM_CREATE message in NewAppCtrl class:
int CNewAppCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
  if (COleControl::OnCreate(lpCreateStruct) == -1)
    return -1;
      
  dlg.Create(IDD_OLDAPP,this);

  CRect rect;
  GetWindowRect(&rect);
  ScreenToClient(rect);
  dlg.SetWindowPos(0,rect.left,rect.top,rect.right,rect.bottom,0);
  return 0;
}

-Compile and test
NewApp.ocx can be put in IE
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:mitrakis
Comment Utility
Listener
0
 

Expert Comment

by:cclain
Comment Utility
you mean ?
0
 
LVL 3

Expert Comment

by:mitrakis
Comment Utility
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...

-Stavi-
0
 

Expert Comment

by:cclain
Comment Utility
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))
    dlg.RedrawWindow(rcBounds,NULL,RDW_INVALIDATE|RDW_ERASE|RDW_UPDATENOW);
  else
  {
    pdc->FillRect(rcBounds,CBrush::FromHandle((HBRUSH)GetStockObject(GRAY_BRUSH)));
    pdc->TextOut(10,10,"NewAppCtrl.ocx");
    pdc->TextOut(10,30,"ActiveX NewAppCtrl");
  }
}
0
 
LVL 4

Expert Comment

by:mandhjo
Comment Utility
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?
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 125
Detect CR LF to each line 12 134
dog bark java program 15 81
EvenOdd challenge 10 81
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 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

10 Experts available now in Live!

Get 1:1 Help Now