Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call a method in a custom ActiveX dll using java/vb script

I have created an ActiveX dll using VB6 and packaged it using the Package & Deployment Wizard which has resulted in a cab file and a demo HTML page.

This ActiveX dll contains a simgle method that returns a string and accepts no arguments.

The trouble I'm having is that when I call the method I always get a "Object does not support this property or method" error. But it does support the method I'm calling.

What I'm trying to achieve is for users to go to a web page that has some java or vb script in it that calls method in my ActiveX and gets the string value returned. The DLL is intended to be called client side.

My test web page is as follows:

<html>
<head>
    <title>SaveClipboardImage.CAB</title>
    <object id="Class1" classid="CLSID:" codebase="SaveClipboardImage.CAB#version=1,0,0,0"></object>
    <script type="text/javascript">
            function displaymessage()
            {
                try
                {
                var filename;

                filename = Class1.SaveClipboardToImage();

                alert(filename);
                }
                catch(e)
                {
                    alert(e.message);
                }               
            }
    </script>
</head>
<body>      
    <input type="BUTTON" onclick="displaymessage()" value="preview" />
</body>
</html>

I'm obviously doing something wrong, but I don't know what. Do I have to do something special to the class in the VB6 project so I can access the method? Am I calling the DLL incorrectly?

Thanks for your help.

like image 978
Chris B Avatar asked May 13 '09 14:05

Chris B


1 Answers

Javascript knows nothing about Class1. You have to get the object into javascript.

Try:

        function displaymessage()
        {
            try
            {
                var filename;
                var class1 = document.getElementById("Class1");
                filename = class1.SaveClipboardToImage();

                alert(filename);
            }
            catch(e)
            {
                alert(e.message);
            }                       
        }
like image 130
Kris Erickson Avatar answered Sep 21 '22 17:09

Kris Erickson