Solved

VB6: ActiveX DLL events in a web page?

Posted on 2002-07-17
4
276 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
Comment Utility
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
Comment Utility
Ask to community support. You could PAQ instead of delete it.
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
Comment Utility
Question placed in PAQ

Computer101
E-E Admin
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

763 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

13 Experts available now in Live!

Get 1:1 Help Now