Solved

VB6: ActiveX DLL events in a web page?

Posted on 2002-07-17
4
277 Views
Last Modified: 2012-06-27
I've already asked this question, but it's not showing up in the Visual Basic Topic Area!  Arrg.  Anyway, here's a duplicate.  I hope this one shows up.

How can I respond to my objects events in a web page?  That is a very open ended question, so I'll be much more specific with an example below?

Create the text file "example.hta" and paste the following:

------------- example.hta start ---------------
<!-- frames -->
<html>
<head>
<HTA:APPLICATION
    ID="oMyApp"
    VERSION="1.0"
    CAPTION="yes"
    MAXIMIZEBUTTON="yes"
    MINIMIZEBUTTON="yes"
    SHOWINTASKBAR="yes"
    SINGLEINSTANCE="yes"
    SYSMENU="yes"
    VERSION="1.0"
    SCROLL="no">
    <title>Hello World Example</title>
    <script language="VBScript">
         Dim myVar
         set myVar = CreateObject("pjtHelloWorld.classHelloWorld")
         
         sub myVar_listenUP(theMessage)
              inComing.innerText = theMessage
         end sub
         
         sub saySomething()
              myVar.sayHello
         end sub
         
         sub getObjectVersion()
              versionNumber.innertext = myVar.getVersion
         end sub
    </script>
</head>
<body>
    <h1 onclick="getObjectVersion()">Hello World Program - The Beginning (version <span id=versionNumber></span>)</h1>
    <div id=inComing onclick="saySomething()">click me</div>
</body>
</html>
------------- example.hta end ---------------

Now, make a new project in VB 6.  Make it an Active-X Dll project.  Name your project "pjtHelloWorld" and name the class file "classHelloWorld".  Open the code window for your class and enter the following code:

------------- classHelloWorld code begin --------------
Public Event listenUp(ByVal message As String)

Public Property Get getVersion() As String
   getVersion = App.Major & "." & App.Minor & "." & App.Revision
End Property

Public Sub sayHello()
   RaiseEvent listenUp("Hello World")
End Sub
------------- classHelloWorld code end   --------------
Save your project.  Make pjtHelloWorld.dll.  Double-click example.hta to run it.

If you click on the title anywhere, you'll see the version number pop in.  The HelloWorld object is being instantiated, and the property is properly fetched when wanted.

Now click the text that says "click me".  Nothing happens.  Why?  I can't figure out how to respond to events that I raise from my active-x dll project in the web page.

Please alter my example such that you can respond to the events from the HTA for the points.

Thanks in advance for your help.

--lankford
0
Comment
Question by:lankford
4 Comments
 

Author Comment

by:lankford
ID: 7162334
Well, I'm answering my own question here.  I don't see where I can delete my question anymore though.  Oh well.

If anyone is interested, it turns out that I couldn't find a way to do it with an ActiveX DLL.  Instead, I compiled my functionality into an ActiveX OCX control that has no visible interface.  This allows you to use an
object tag like the following:

<object
  id="myOCX"
  classid="CLSID:7A97D874-3CA6-4E1D-9F2A-70CB9119FB09"
  width="1"
  height="1">
</object>

Having this tag available when you load the page into the browser's memory allows it to hook the events together.  So, in my VBScript, I could respond to the event "myEvent" like so:

sub myOCX_myEvent(parameters)
     ' respond here
end sub

--lankford
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7169982
Ask to community support. You could PAQ instead of delete it.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8013796
lankford, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 8096158
Question placed in PAQ

Computer101
E-E Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

932 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

11 Experts available now in Live!

Get 1:1 Help Now