Solved

encapsulate a dll

Posted on 2004-08-05
12
419 Views
Last Modified: 2013-12-25
Hi,
  I need to call in ASP an activex.  usaualy I call it like this :  Set inet = Server.CreateObject("InetCtls.Inet")

but I made an activex (longtime ago) that I call in my ASP:   Set inet = Server.CreateObject("f1.Class1")

This object was made with the IneCtls in VB it has a few lines. (I think it's encapsulate) but I don't remember how I did that.  Someone supported me that time and I lost that source.     I was able to use all the function/procedure of InetCtls.

Can someone assist me with that?
it's a bit urgent

   Bruno.


0
Comment
Question by:Buz007
  • 5
  • 5
  • 2
12 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
Not sure if this is what you mean, but:

You create an ActiveX DLL and add a reference to the InetCtls component, add a form to your app and plonk an Inet control on it.  You then simply create Public subs/functions that themselves can use the Inet control.

Then from your ASP page you would have something like:

    Set oMyObj = Server.CreateObject("YourProject.YourClass")
    oMyObj.SomeFunctionName         '<-- A public function in your DLL that does something using the Inet control



Hope this makes sense.
0
 

Author Comment

by:Buz007
Comment Utility
That's exactly what I want to do.  


  >> You create an ActiveX DLL and add a reference to the InetCtls component,  :
               I Know How to do it

>>  add a form to your app and plonk an Inet control on it.
               I Know How to do it
         
>>   You then simply create Public subs/functions that themselves can use the Inet control.
   Here is my question.  How can I make a function that uses an Inet control.  I know it's a newbie question but can you show my the syntax :-s  

What I did 2 years ago is that in an ASP source :
'    Set inet = Server.CreateObject("InetCtls.Inet")
    Set inet = Server.CreateObject("getDta.Class1")
    inet.RequestTimeOut = 20
    sHTML = inet.OpenURL(TheHTMLPage)

and the VB source as only 1 function or sub but I could use all the function of InetCtls.
 

  thanks

    Bruno F

 
 
0
 
LVL 52

Expert Comment

by:Carl Tawn
Comment Utility
In that case is sounds like the sub must have exposed the Inet control directly. Something like:

Public Function Default() As InetCtlsObjects.Inet

    Default = myForm.Inet1           '<-- Return the Inet control

End Function

This assumes that you have  a form in your dll with an inet control on it.

In order to use this like in you ASP snippet you will have to go into VB's object browser, select your class in the left hand list.  This will display all of the methods of your class in the right hand pane.  Right click the 'Default' method and select properties from the popup menu.

This will bring up the Procedure Attributes dialog,  select advanced, then in the Procedure ID combo select (default).

Hope this helps.
0
 
LVL 3

Accepted Solution

by:
TILL earned 250 total points
Comment Utility
An easyer way to do what you need, is to use Microsoft XML to read the web page for you. In your VB project, add a reference to Microsoft XML Parser ( I Used version 3.0) and add the folowing code in your public class:

Public Function getWebPage(URL As String) As String
    Dim obj As MSXML2.XMLHTTP30
    Set obj = New MSXML2.XMLHTTP30
    On Error Resume Next
    If Err.Number = 0 Then
        obj.open "GET", URL, False, False, False
        obj.send
        getWebPage = obj.responseText
    Else
        getWebPage = ""
    End If
    Set obj = Nothing
End Function

you can use this in an asp page like this:

<%
   Dim obj
   Set obj = Server.CreateObject("MyCom.MyClass")
   Response.Write obj.getWebPage("http://www.experts-exchange.com")
   Set obj = nothing
%>


Best of luck,
TILL.
0
 

Author Comment

by:Buz007
Comment Utility
Hi Till,
  Thank you for that example.  Why you prefer XML to InetCtls object?

    Bruno F.
0
 
LVL 3

Expert Comment

by:TILL
Comment Utility
 Hi,
  I did some tests a long time ago and MSXML was better that inet regarding the speed of html fetching.
  By the way... what's with the B grade?

TILL.

 

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:Buz007
Comment Utility
Hi,
  It's not exactly what I wanted with your answer (but it does the work!), I have to make a function what I didn't have to do with my old version.  I could use all the function of InetCtls. (Now I will use the MSXML).  My original question was how to encapsulate an object to use all the functionnality without having to make a function for each one. In fact I want to do this because I'm developping an other application with others objects and I want to protect my work from an employer/customer so I made my "own" object. (Thant I can if I want add some features)

 If you can send me that info, I'll change it to an A grade.

ref :
>>What I did 2 years ago is that in an ASP source :
>>'    Set inet = Server.CreateObject("InetCtls.Inet")
>>    Set inet = Server.CreateObject("getDta.Class1")
>>    inet.RequestTimeOut = 20
>>    sHTML = inet.OpenURL(TheHTMLPage)


  Bruno F.
0
 
LVL 3

Expert Comment

by:TILL
Comment Utility
In your Getdts VB dll project, add this function to Class1 :

Public Function getInetObject() As Object
    Set getInetObject = Form1.Inet1
End Function

When you use this script, it works.

<%
  Set inet = Server.CreateObject("InetCtls.Inet")
  Set inet1 = Server.CreateObject("getDta.Class1")
  set inet=inet1.getInetObject

  inet.RequestTimeOut = 20
  sHTML = inet.OpenURL("http://www.experts-exchange.com")
  Response.Write sHtml
%>


It works even if you skip this part.
  Set inet1 = Server.CreateObject("getDta.Class1")
  Set inet=inet1.getInetObject

So, basically, I don't know why you used the wrapper originally.

0
 

Author Comment

by:Buz007
Comment Utility
I did that because I don't want the employer and or customer know what object I use.

but I dont use the 1st line of the example


'    Set inet = Server.CreateObject("InetCtls.Inet")    ''''' This line is in comment
    Set inet = Server.CreateObject("getDta.Class1")
    inet.RequestTimeOut = 20
    sHTML = inet.OpenURL(TheHTMLPage)

so in ASP it's only those 3 lines

    Set inet = Server.CreateObject("getDta.Class1")
    inet.RequestTimeOut = 20
    sHTML = inet.OpenURL(TheHTMLPage)

so what's the function I have to make in my getDta activex project?

  Bruno F.
0
 
LVL 3

Expert Comment

by:TILL
Comment Utility
Public Function getInetObject() As Object

    Set getInetObject = Form1.Inet1
End Function


This takes a Inet control instance from the form1 and returns the reference.

0
 

Author Comment

by:Buz007
Comment Utility
in your example, you make reference to form1. I add the form but I have an error when compiling : method or data member not found with form1.inet
I have as a reference msinet.ocx

but, I think I don't explain well (my poor english)


in ASP I want to do this :
<%
    Set inet = Server.CreateObject("getDta.Class1")
    inet.RequestTimeOut = 20
    sHTML = inet.OpenURL(TheHTMLPage)
response.write sHTML
%>

in vb I think I need something like this :
' reference ' MSINET.OCX (microsoft internet transfer control 6.0)
' class name = class1
'dll Name = getDta.dll

Public Function ???() As ????
'  ????

End Function


   Bruno F.



0
 
LVL 3

Expert Comment

by:TILL
Comment Utility
The function needs to return an object because it cannot return a Inet instance.
On the other hand, the function returns the instance of the inet control that exists on one of your forms existing in the dll.  In my example, I had a Inet control named inet1 on a form named form1.
I needed to do this because Inet control is not a windowless control which means that it requires a window/container to store it.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

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

8 Experts available now in Live!

Get 1:1 Help Now