Solved

encapsulate a dll

Posted on 2004-08-05
12
421 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
ID: 11731158
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
ID: 11732252
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
ID: 11733430
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 3

Accepted Solution

by:
TILL earned 250 total points
ID: 11750806
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
ID: 11752349
Hi Till,
  Thank you for that example.  Why you prefer XML to InetCtls object?

    Bruno F.
0
 
LVL 3

Expert Comment

by:TILL
ID: 11752369
 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
 

Author Comment

by:Buz007
ID: 11752848
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
ID: 11753013
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
ID: 11753464
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
ID: 11753537
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
ID: 11754230
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
ID: 11756633
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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