?
Solved

Convert ActiveX DLL to OCX Control

Posted on 2003-03-10
10
Medium Priority
?
2,927 Views
Last Modified: 2010-08-05
Someone is using Matlab which supposedly will not accept my ActiveX DLLs -- it only accepts ActiveX Controls (OCXs). Provided that is true, is there an easy way to wrap my DLL inside an OCX without having to do a lot of work?

I also need to keep them separate, as legacy software uses the DLL. The DLL had to run in-process and be fast (i.e., little overhead) which is why the DLL was chosen over EXE or OCX.
0
Comment
Question by:GivenRandy
[X]
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
  • 5
  • 4
10 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 8105807
Basically it will consist of creating a new usercontrol project, running the interface wizard to create some basic control properties and copying your DLL class code into the usercontrol.  
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 800 total points
ID: 8105838
Of course maintenance becomes a pain if you change that class... Maybe better to add that class to the OCX project and delegate all the properties from the OCX.  In other words the OCX creates an object based on the class and calls each property/method from similarly named properties/methods.
0
 
LVL 9

Author Comment

by:GivenRandy
ID: 8106030
The latter is what I expected. More input will be appreciated.

p.s., this is VB6.

p.p.s., PaulHews: long time, no see!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Expert Comment

by:phildaley
ID: 8106255
Without trying it, I would have thought you would write a UserControl that has all the same methods (subs and functions) and properties of the DLL. The UserControl would just delegate or call the DLL routines. You could then keep the DLL as it is and supply and register it as part of the installation.

For example, suppose your DLL was called MyData and it had a class CCustomer that had the following method:
Public FindName(sName as string) as Long
    ' Find customer ID whose name is sName
    .
    .
   
end sub

You would then code a method into the UserControl such as:
Public CustomerFindName(sName as string)
    Dim cCust as MyData.CCustomer
    set cCust = new MyData.CCustomer
    CustomerFindName = cCust.FindName(sName)
    set cCust = Nothing
end sub

Repeat for each method/property of the MyData DLL which you want to expose from the UserControl.
0
 
LVL 9

Author Comment

by:GivenRandy
ID: 8114299
PaulHews, that was the original plan and what, unfortunately, I probably will have to do.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 8114609
If it represents a lot of work to do the delegation code manually, you could probably write a program that goes through the cls file, picks out all the public properties/methods and writes the delegation code for you.

>long time, no see!

Yes, nice to see a familiar face. :) Hope things are good for you.
0
 
LVL 9

Author Comment

by:GivenRandy
ID: 8933765
PaulHews, I finally go to this phase on the other project (funny how projects and task shift around here). It took about 30 minutes to do just that and it worked well as an OCX on other projects. Turns out that MATLAB will not allow pass-by-reference, so some of the functions may have to be re-written, which may be a pain. If you know any more about this, I can give more points or open another question.
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 8934035
You're using matlab com builder?  Sorry, don't know much about it.  
0
 
LVL 9

Author Comment

by:GivenRandy
ID: 8934600
I will try to keep posting comments here for archival purposes. Supposedly 6.5 (r13) will handle this, which we are using. Our initial attempt at it failed, but we will be contacting MathWorks (which should fall under our maintenance fee with them, which is pricey, but useful). They did have one post about it, but as I mentioned, we got an initial error:

http://www.mathworks.com/company/digest/march03/activeX.shtml
0
 
LVL 9

Author Comment

by:GivenRandy
ID: 8994627
The pass-by-reference does work for most cases, now. Mathworks is still investigating why it does not work for 1) array of strings and 2) when called function uses Redim Preserve (which does not make sense because it does allow for Redim). If you have ANY comments on this, please make them at:

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20683152.html
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 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