CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2004
    Posts
    133

    Question How to use TLB file to access methods in a scripting client

    Hi all

    i have an IDL file, from whcih i can get the TLB file, now using this TLB, can i have an scripting client buit using java/vb script acces all the com methods and even suport the callback

    i dont have the COM Dll for the IDL, we have app which only give the IDL.


    regards
    pradish

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: How to use TLB file to access methods in a scripting client

    The code resides in the DLL. What would you be calling if you don't have the DLL?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Nov 2004
    Posts
    133

    Re: How to use TLB file to access methods in a scripting client

    yeah.you are right. the queston was not framed properly
    i have dll, but it is not COM dll, i thought tlb is enough for the
    scripting clients and can make call in to the regular dll, but i
    guess it will not work.

    so i am writing a COM wrapper ove this regulat dll, then how
    do i call a COM method , which returns a interface pointer and
    that interface pointer is not derived from IDispatch.


    Thank you cilu for the correction


    regards
    pradish

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to use TLB file to access methods in a scripting client

    A good book to learn about this is Beginning ATL 3 COM Programming.

  5. #5
    Join Date
    Sep 2002
    Location
    Singapore
    Posts
    673

    Re: How to use TLB file to access methods in a scripting client

    Quote Originally Posted by pradish View Post
    yeah.you are right. the queston was not framed properly
    i have dll, but it is not COM dll, i thought tlb is enough for the
    scripting clients and can make call in to the regular dll, but i
    guess it will not work.

    so i am writing a COM wrapper ove this regulat dll, then how
    do i call a COM method , which returns a interface pointer and
    that interface pointer is not derived from IDispatch.


    Thank you cilu for the correction


    regards
    pradish
    The COM interface pointer have to be derived from IDispatch, else you cannot call your methods in Javascript and VBscript.

  6. #6
    Join Date
    Nov 2004
    Posts
    133

    Re: How to use TLB file to access methods in a scripting client

    Thank you all for the replies...

    i am able to call a interface method, but how do i implement a callback
    supposing my components supports the connection point and calls

    Fire_OnNewEvent();

    what code should i write in javascript on a HTML page to catch this event




    regards
    pradish

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to use TLB file to access methods in a scripting client

    Search google for "COM JavaScript connection points" and look at the first 3 hits.

  8. #8
    Join Date
    Nov 2004
    Posts
    133

    Re: How to use TLB file to access methods in a scripting client

    i have already done that, all the three are quires or problems they face while implementing callbaks , with one very compicated example in code project.

    this is my HTML code , wherein the interface method call is working , but the callback nerver gets called

    <html>
    <head>
    <title>My Com Component</title>

    <OBJECT ID="MyObj" CLASSID="CLSID:5F19E5E7-4617-4D24-A30D-F4D5C2605E66">

    </OBJECT>

    <script language="javascript" type="text/javascript">

    function InvokeComMethod()
    {
    alert("The InvokeComMethod ");
    var returnCode = MyObj.AddAndFill(10,90);
    alert("The Sum of Two numbers is = "+returnCode);
    }

    function MyComComponent_onload()
    {
    InvokeComMethod();
    }

    function MyComComponent_onunload()
    {
    MyObj.Dispose();
    }

    </script>
    //The callback code , TakeIT is a callback function (i used the
    //connection point wizard to generate the code and Fire_TakeIT() is also
    //succesfull, but this code never gets called
    <script language="javascript" type="text/javascript">
    MyObj.attachEvent('TakeIT', onActionDone);
    function onActionDone()
    {
    alert("!")
    }

    </script>

    </head>
    <body onload="MyComComponent_onload();" onunload="MyComComponent_onunload();">
    <h1>My Com Component</h1>

    </body>
    </html>

  9. #9
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: How to use TLB file to access methods in a scripting client

    What happens when you step through the code in a debugger?

    Open the COM dll project in Visual Studio and point the startup exe to IE and pass in the test web page as a startup parameter. Then set breakpoints on the on load function, create connection point, and so on to see if your break points get hit.

    The end goal here is to determine where the issue is. It is the scripting code or inside the COM server? Btw, how do you write the COM dll? Did you use ATL?
    Last edited by Arjay; July 24th, 2009 at 09:16 AM.

  10. #10
    Join Date
    Nov 2004
    Posts
    133

    Thumbs up Re: How to use TLB file to access methods in a scripting client

    Hi all,

    Thankyou for all the inputs.

    The problem here was that for IE as a client to support the callback , the CoClass should implement IProvideClassInfo2Impl more in this KB

    http://support.microsoft.com/kb/200839

    after doing the changes , it worked fine.


    regards
    pradish

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured