Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

From EXE to OCX

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
soso071898
Asked:
soso071898
  • 3
  • 2
  • 2
  • +2
1 Solution
 
Gandalf32Commented:
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
 
soso071898Author Commented:
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
 
mandhjoCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
cclainCommented:
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
 
mitrakisCommented:
Listener
0
 
cclainCommented:
you mean ?
0
 
mitrakisCommented:
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
 
cclainCommented:
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
 
mandhjoCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now