Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Integrating custom ActiveX control into HTML document with Javascript

Status
Not open for further replies.

djjd47130

Programmer
Nov 1, 2010
480
0
0
US
I started playing with windows desktop gadgets, which are essentially mini web pages. I'm building an ActiveX control using Delphi and importing this control into the HTML doc. Now I'm not too familiar with HTML/javascript, but very familiar with Delphi. I need to be able to interact with this ActiveX component from Javascript, and be able to trigger events in the component to execute event handlers in the javascript.

I have it declared like this:
Code:
<head>
  <script type="text/jscript" language="jscript">
    function init()
    {
      var oBackground = document.getElementById("imgBackground");
      oBackground.src = "url(GadgetBackSmall.png)";
      //Somehow set my component's event "OnMyNumberChanged" to function "MyNumberChanged"
      //id of component is "JDNG"
    }
    function MyNumberChanged(Sender, Value)
    {
      //In Delphi...
      //> Sender: TObject;
      //> Value: Integer;
      //Somehow write for example Width of component, or other properties
    }
  </script>
</head>
<body onload="init()">
  <g:background id="imgBackground">
    <object classid="clsid:E09288CA-7458-4CD8-AD50-2B8AE8D06019" id="JDNG"
      style="position:relative;float:left;
      width:100%;height:100%;left:10px;top:10px;border:none;">
    </object>
  </g:background>
</body>

for example, if I have my own property in this component called "MyNumber" then how would I read/write MyNumber from javascript?

I assume in the onload() event handler I will have to assign some event handler to an appropriate event, such as "OnMyNumberChanged". Or do I set this in the declaration of <object />?

JD Solutions
 
Hi JD Solutions,

Here's a tip - Javascript functions can have parameters, and I personally thimk "document.getElementById" is lazy programming.

function init(object JDNG) { //call JDNG.OnMyNumberChanged }

So why does the <object> declaration have to be in <body> ?

I'm not an expert but there should be a more coherent approach,

Yours, Jim.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top