Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. How to using the second IDispatch of a COM object in VBScript

How to using the second IDispatch of a COM object in VBScript

Scheduled Pinned Locked Moved ATL / WTL / STL
questionc++comdesigntutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bojinyu
    wrote on last edited by
    #1

    I design a COM object by ATL, which has two IDispath. Default dispatch is IPlot2D, and the second is IMIDraw. IMIDraw has a method Plot(), how do I launch Plot() method?

    L P 2 Replies Last reply
    0
    • B bojinyu

      I design a COM object by ATL, which has two IDispath. Default dispatch is IPlot2D, and the second is IMIDraw. IMIDraw has a method Plot(), how do I launch Plot() method?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You can not. There is a rule(standard) of COM which states that you can only have one dispatch interface in the COM object. The reason for that is that late binding clients(VBS) use QueryInterface(IDispatch)/Invoke(methodID) for everything. 1. You can try to implement IMIDraw as separate object and expose it through a method of IPlot2D. 2. If they are polymorphic you can try to derive IMIDraw from IPlot2D, this way you can expose both interfaces and not violate the rule.

      1 Reply Last reply
      0
      • B bojinyu

        I design a COM object by ATL, which has two IDispath. Default dispatch is IPlot2D, and the second is IMIDraw. IMIDraw has a method Plot(), how do I launch Plot() method?

        P Offline
        P Offline
        pba_
        wrote on last edited by
        #3

        In addition to the previous reply, you can choose to implement your own IDispatch which will take care of all the methods for both interfaces. However, it is not the best solution, and you will have to take care to name clashes.

        B 1 Reply Last reply
        0
        • P pba_

          In addition to the previous reply, you can choose to implement your own IDispatch which will take care of all the methods for both interfaces. However, it is not the best solution, and you will have to take care to name clashes.

          B Offline
          B Offline
          bojinyu
          wrote on last edited by
          #4

          Thank you very much, solon. I put a new method Plot0() in IPlot2D, and Plot() is launch there. It's OK. Thanks again.

          P 1 Reply Last reply
          0
          • B bojinyu

            Thank you very much, solon. I put a new method Plot0() in IPlot2D, and Plot() is launch there. It's OK. Thanks again.

            P Offline
            P Offline
            pba_
            wrote on last edited by
            #5

            this is not exactly what I meant – I was talking about a custom implementation of IDispatch, where you redirect the Invoke call to the appropriate IDispatch implementation.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups