Plzzzzzzzzzzz Help for callback function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sajin

    #1

    Plzzzzzzzzzzz Help for callback function

    Hi All..

    We are using VB .Net 2005 for implementing an API. API needs to
    generate events. For this client wants us to use Windows Callback
    (delegate implementation) . The intention of using Windows Callback is
    to generalise our API so that it can be compatible with any other
    language e.g. C++.

    Using normal delegates will not help us since delegates is a VB.Net
    feature and any other language cant make a use of it. Could please
    someone suggest us how to write a Windows Callback function in VB.Net?

    Any help will be appreciated :)

    Regards
    -AlertAdmin

  • Michel Posseth [MCP]

    #2
    Re: Plzzzzzzzzzzz Help for callback function

    Huh ???
    We are using VB .Net 2005 for implementing an API. API needs to
    generate events. For this client wants us to use Windows Callback
    (delegate implementation) . The intention of using Windows Callback is
    to generalise our API so that it can be compatible with any other
    language e.g. C++.
    >
    Using normal delegates will not help us since delegates is a VB.Net
    feature
    Delegates are a .Net framework feature there is nothing VB about using
    delegates

    http://msdn2.microsoft.com/en-us/library/17sde2xt.aspx


    However Classic event structures in VB

    Public event eMyEvent (byval justavalue as sting )

    raiseevent ("helloworld ")

    Is by the compiler translated to a delegate structure


    So if you want to comunicate with a event mechanism to legacy programs you
    can do 2 things

    1 comunicate with the event mechanism ( 1- way )
    2. comunicate over the idispatch interface ( 2- way event comunication
    possible in latebound way by just calling methods on Object pointers that
    are stored in property`s )

    Both would be easy to implement with a litle help of COM

    I wrote once a COM Server prog in VB.Net 2003 this way that needed to
    comunicate wit several VB6 , Delphi and a Clipper clients


    HTH

    michel







    "sajin" <sajin@iprlab.c omschreef in bericht
    news:1176126933 .695954.96050@b 75g2000hsg.goog legroups.com...
    Hi All..
    >
    We are using VB .Net 2005 for implementing an API. API needs to
    generate events. For this client wants us to use Windows Callback
    (delegate implementation) . The intention of using Windows Callback is
    to generalise our API so that it can be compatible with any other
    language e.g. C++.
    >
    Using normal delegates will not help us since delegates is a VB.Net
    feature and any other language cant make a use of it. Could please
    someone suggest us how to write a Windows Callback function in VB.Net?
    >
    Any help will be appreciated :)
    >
    Regards
    -AlertAdmin
    >

    Comment

    • sajin

      #3
      Re: Plzzzzzzzzzzz Help for callback function

      On Apr 10, 12:44 am, "Michel Posseth [MCP]" <msn...@posseth .com>
      wrote:
      Huh ???
      >
      We are using VB .Net 2005 for implementing an API. API needs to
      generate events. For this client wants us to use Windows Callback
      (delegate implementation) . The intention of using Windows Callback is
      to generalise our API so that it can be compatible with any other
      language e.g. C++.
      >
      Using normal delegates will not help us since delegates is a VB.Net
      feature
      >
      Delegates are a .Net framework feature there is nothing VB about using
      delegates
      >
      http://msdn2.microsoft.com/en-us/library/17sde2xt.aspx
      >
      However Classic event structures in VB
      >
      Public event eMyEvent (byval justavalue as sting )
      >
      raiseevent ("helloworld ")
      >
      Is by the compiler translated to a delegate structure
      >
      So if you want to comunicate with a event mechanism to legacy programs you
      can do 2 things
      >
      1 comunicate with the event mechanism ( 1- way )
      2. comunicate over the idispatch interface ( 2- way event comunication
      possible in latebound way by just calling methods on Object pointers that
      are stored in property`s )
      >
      Both would be easy to implement with a litle help of COM
      >
      I wrote once a COM Server prog in VB.Net 2003 this way that needed to
      comunicate wit several VB6 , Delphi and a Clipper clients
      >
      HTH
      >
      michel
      >
      "sajin" <s...@iprlab.co mschreef in berichtnews:117 6126933.695954. 96050@b75g2000h sg.googlegroups .com...
      >
      >
      >
      Hi All..
      >
      We are using VB .Net 2005 for implementing an API. API needs to
      generate events. For this client wants us to use Windows Callback
      (delegate implementation) . The intention of using Windows Callback is
      to generalise our API so that it can be compatible with any other
      language e.g. C++.
      >
      Using normal delegates will not help us since delegates is a VB.Net
      feature and any other language cant make a use of it. Could please
      someone suggest us how to write a Windows Callback function in VB.Net?
      >
      Any help will be appreciated :)
      >
      Regards
      -AlertAdmin- Hide quoted text -
      >
      - Show quoted text -

      Hi Mich,

      Thanks for your explanation. But we didnt get the point that you were
      trying to explain. To just clarify what we want; There are 2 parts of
      the project API and Add-in. Currently both are written in VB.Net. API
      fire events to Add-in and Add-in in turn needs to capture it and
      perform some function.
      Now, the firing events from API should be so general that if at a
      later point, Add-in is wriiten in C++ then also API should be able to
      fire the events. And this will be possible only if we use Windows
      Callback function. The Windows Callback function will be written in
      Add-in and it will be fired from the API. So, we are stuck at this
      point of how to use Windows Callback in VB.Net

      Can you please post the code or atleast the snippet of COM server
      prog. Or any other point that can help us would be of great help.


      Regards
      -AlertAdmin






      Comment

      • Michel Posseth  [MCP]

        #4
        Re: Plzzzzzzzzzzz Help for callback function


        Well here is the link to a small COM example i once showed in this newsgroup




        you might want to look at this link to , to make sure we talk about the same
        thingy

        http://msdn2.microsoft.com/en-us/lib...f0(vs.80).aspx

        regards

        Michel




        "sajin" <sajin@iprlab.c omschreef in bericht
        news:1176189533 .308754.229650@ n76g2000hsh.goo glegroups.com.. .
        On Apr 10, 12:44 am, "Michel Posseth [MCP]" <msn...@posseth .com>
        wrote:
        >Huh ???
        >>
        We are using VB .Net 2005 for implementing an API. API needs to
        generate events. For this client wants us to use Windows Callback
        (delegate implementation) . The intention of using Windows Callback is
        to generalise our API so that it can be compatible with any other
        language e.g. C++.
        >>
        Using normal delegates will not help us since delegates is a VB.Net
        feature
        >>
        >Delegates are a .Net framework feature there is nothing VB about using
        >delegates
        >>
        >http://msdn2.microsoft.com/en-us/library/17sde2xt.aspx
        >>
        >However Classic event structures in VB
        >>
        >Public event eMyEvent (byval justavalue as sting )
        >>
        >raiseevent ("helloworld ")
        >>
        >Is by the compiler translated to a delegate structure
        >>
        >So if you want to comunicate with a event mechanism to legacy programs
        >you
        >can do 2 things
        >>
        >1 comunicate with the event mechanism ( 1- way )
        >2. comunicate over the idispatch interface ( 2- way event comunication
        >possible in latebound way by just calling methods on Object pointers that
        >are stored in property`s )
        >>
        >Both would be easy to implement with a litle help of COM
        >>
        >I wrote once a COM Server prog in VB.Net 2003 this way that needed to
        >comunicate wit several VB6 , Delphi and a Clipper clients
        >>
        >HTH
        >>
        >michel
        >>
        >"sajin" <s...@iprlab.co mschreef in
        >berichtnews:11 76126933.695954 .96050@b75g2000 hsg.googlegroup s.com...
        >>
        >>
        >>
        Hi All..
        >>
        We are using VB .Net 2005 for implementing an API. API needs to
        generate events. For this client wants us to use Windows Callback
        (delegate implementation) . The intention of using Windows Callback is
        to generalise our API so that it can be compatible with any other
        language e.g. C++.
        >>
        Using normal delegates will not help us since delegates is a VB.Net
        feature and any other language cant make a use of it. Could please
        someone suggest us how to write a Windows Callback function in VB.Net?
        >>
        Any help will be appreciated :)
        >>
        Regards
        -AlertAdmin- Hide quoted text -
        >>
        >- Show quoted text -
        >
        >
        Hi Mich,
        >
        Thanks for your explanation. But we didnt get the point that you were
        trying to explain. To just clarify what we want; There are 2 parts of
        the project API and Add-in. Currently both are written in VB.Net. API
        fire events to Add-in and Add-in in turn needs to capture it and
        perform some function.
        Now, the firing events from API should be so general that if at a
        later point, Add-in is wriiten in C++ then also API should be able to
        fire the events. And this will be possible only if we use Windows
        Callback function. The Windows Callback function will be written in
        Add-in and it will be fired from the API. So, we are stuck at this
        point of how to use Windows Callback in VB.Net
        >
        Can you please post the code or atleast the snippet of COM server
        prog. Or any other point that can help us would be of great help.
        >
        >
        Regards
        -AlertAdmin
        >
        >
        >
        >
        >
        >

        Comment

        • sajin

          #5
          Re: Plzzzzzzzzzzz Help for callback function

          Hi Mich,

          I am still bit confused, the scenario here is that lets say i have API
          which is written in VB .net which will communicate with the Addin
          (Office powerpoint addin). We need to generalize our API such that if
          in future any addin which is written in other language also should be
          able to communicate with our API.

          So we thought of using delegates (Callback function)

          This is what we have done
          1. In API we have written the following

          Public Delegate Sub InvokeDel()

          Public Sub InvokeMethod(By Val a As Addin)
          'Here Addin is the object of the OfficeAddin
          Dim getDel As InvokeDel
          getDel = AddressOf a.test
          getDel.Invoke()
          End Sub

          2. In the addin lets say we have a method that has to be invoked
          through the delegate

          The following method we have written in Addin

          Public Sub test()
          MsgBox("I am in MyBaseClass called through delegates")
          End Sub

          3. Now in the addin we created an object of API and called the method
          "InvokeMeth od" with the argument as object of addin

          Dim obj As New Addin
          Dim objApI As New API
          objApI.InvokeMe thod(obj)
          4.Here in this we have to have the reference of API in the addin as
          well as Addin in API (since we have to get the method name of addin)

          5. The above point is little confusing since it is cross referencing
          the dll each other and our API will not be generalized.
          6. Lets say if we have C++ addin , how we can do it...

          If i am in wrong track, can you plzzz help me with this



          Regards
          -Sajin




          On Apr 10, 10:59 pm, "Michel Posseth [MCP]" <M...@posseth.c omwrote:
          Well here is the link to a small COM example i once showed in this newsgroup
          >
          http://groups.google.nl/group/micros...anguages.vb/br...
          >
          you might want to look at this link to , to make sure we talk about the same
          thingy
          >
          http://msdn2.microsoft.com/en-us/lib...f0(vs.80).aspx
          >
          regards
          >
          Michel
          >
          "sajin" <s...@iprlab.co mschreef in berichtnews:117 6189533.308754. 229650@n76g2000 hsh.googlegroup s.com...
          >
          >
          >
          On Apr 10, 12:44 am, "Michel Posseth [MCP]" <msn...@posseth .com>
          wrote:
          Huh ???
          >
          We are using VB .Net 2005 for implementing an API. API needs to
          generate events. For this client wants us to use Windows Callback
          (delegate implementation) . The intention of using Windows Callback is
          to generalise our API so that it can be compatible with any other
          language e.g. C++.
          >
          Using normal delegates will not help us since delegates is a VB.Net
          feature
          >
          Delegates are a .Net framework feature there is nothing VB about using
          delegates
          >>
          However Classic event structures in VB
          >
          Public event eMyEvent (byval justavalue as sting )
          >
          raiseevent ("helloworld ")
          >
          Is by the compiler translated to a delegate structure
          >
          So if you want to comunicate with a event mechanism to legacy programs
          you
          can do 2 things
          >
          1 comunicate with the event mechanism ( 1- way )
          2. comunicate over the idispatch interface ( 2- way event comunication
          possible in latebound way by just calling methods on Object pointers that
          are stored in property`s )
          >
          Both would be easy to implement with a litle help of COM
          >
          I wrote once a COM Server prog in VB.Net 2003 this way that needed to
          comunicate wit several VB6 , Delphi and a Clipper clients
          >
          HTH
          >
          michel
          >
          "sajin" <s...@iprlab.co mschreef in
          berichtnews:117 6126933.695954. 96050@b75g2000h sg.googlegroups .com...
          >
          Hi All..
          >
          We are using VB .Net 2005 for implementing an API. API needs to
          generate events. For this client wants us to use Windows Callback
          (delegate implementation) . The intention of using Windows Callback is
          to generalise our API so that it can be compatible with any other
          language e.g. C++.
          >
          Using normal delegates will not help us since delegates is a VB.Net
          feature and any other language cant make a use of it. Could please
          someone suggest us how to write a Windows Callback function in VB.Net?
          >
          Any help will be appreciated :)
          >
          Regards
          -AlertAdmin- Hide quoted text -
          >
          - Show quoted text -
          >
          Hi Mich,
          >
          Thanks for your explanation. But we didnt get the point that you were
          trying to explain. To just clarify what we want; There are 2 parts of
          the project API and Add-in. Currently both are written in VB.Net. API
          fire events to Add-in and Add-in in turn needs to capture it and
          perform some function.
          Now, the firing events from API should be so general that if at a
          later point, Add-in is wriiten in C++ then also API should be able to
          fire the events. And this will be possible only if we use Windows
          Callback function. The Windows Callback function will be written in
          Add-in and it will be fired from the API. So, we are stuck at this
          point of how to use Windows Callback in VB.Net
          >
          Can you please post the code or atleast the snippet of COM server
          prog. Or any other point that can help us would be of great help.
          >
          Regards
          -AlertAdmin- Hide quoted text -
          >
          - Show quoted text -

          Comment

          • Michel Posseth  [MCP]

            #6
            Re: Plzzzzzzzzzzz Help for callback function

            Hello Sajin

            I would just write a COM interface , this wil make sure that your program is
            capable of comunicating to .Net and legacy apps ( C++ , Delphi , VB6 etc
            etc )
            MS uses this with there complete Office line it is proven technology works
            fine and verry easy to implement in anny .Net app
            In this case you can invoke the methods directly or through an interface

            In my opinion COM is the way to go in the by you described situation

            regards

            Michel



            "sajin" <sajin@iprlab.c omschreef in bericht
            news:1176294502 .896318.190500@ b75g2000hsg.goo glegroups.com.. .
            Hi Mich,
            >
            I am still bit confused, the scenario here is that lets say i have API
            which is written in VB .net which will communicate with the Addin
            (Office powerpoint addin). We need to generalize our API such that if
            in future any addin which is written in other language also should be
            able to communicate with our API.
            >
            So we thought of using delegates (Callback function)
            >
            This is what we have done
            1. In API we have written the following
            >
            Public Delegate Sub InvokeDel()
            >
            Public Sub InvokeMethod(By Val a As Addin)
            'Here Addin is the object of the OfficeAddin
            Dim getDel As InvokeDel
            getDel = AddressOf a.test
            getDel.Invoke()
            End Sub
            >
            2. In the addin lets say we have a method that has to be invoked
            through the delegate
            >
            The following method we have written in Addin
            >
            Public Sub test()
            MsgBox("I am in MyBaseClass called through delegates")
            End Sub
            >
            3. Now in the addin we created an object of API and called the method
            "InvokeMeth od" with the argument as object of addin
            >
            Dim obj As New Addin
            Dim objApI As New API
            objApI.InvokeMe thod(obj)
            4.Here in this we have to have the reference of API in the addin as
            well as Addin in API (since we have to get the method name of addin)
            >
            5. The above point is little confusing since it is cross referencing
            the dll each other and our API will not be generalized.
            6. Lets say if we have C++ addin , how we can do it...
            >
            If i am in wrong track, can you plzzz help me with this
            >
            >
            >
            Regards
            -Sajin
            >
            >
            >
            >
            On Apr 10, 10:59 pm, "Michel Posseth [MCP]" <M...@posseth.c omwrote:
            >Well here is the link to a small COM example i once showed in this
            >newsgroup
            >>
            >http://groups.google.nl/group/micros...anguages.vb/br...
            >>
            >you might want to look at this link to , to make sure we talk about the
            >same
            >thingy
            >>
            >http://msdn2.microsoft.com/en-us/lib...f0(vs.80).aspx
            >>
            >regards
            >>
            >Michel
            >>
            >"sajin" <s...@iprlab.co mschreef in
            >berichtnews:11 76189533.308754 .229650@n76g200 0hsh.googlegrou ps.com...
            >>
            >>
            >>
            On Apr 10, 12:44 am, "Michel Posseth [MCP]" <msn...@posseth .com>
            wrote:
            >Huh ???
            >>
            We are using VB .Net 2005 for implementing an API. API needs to
            generate events. For this client wants us to use Windows Callback
            (delegate implementation) . The intention of using Windows Callback
            is
            to generalise our API so that it can be compatible with any other
            language e.g. C++.
            >>
            Using normal delegates will not help us since delegates is a VB.Net
            feature
            >>
            >Delegates are a .Net framework feature there is nothing VB about
            >using
            >delegates
            >>>>
            >However Classic event structures in VB
            >>
            >Public event eMyEvent (byval justavalue as sting )
            >>
            >raiseevent ("helloworld ")
            >>
            >Is by the compiler translated to a delegate structure
            >>
            >So if you want to comunicate with a event mechanism to legacy programs
            >you
            >can do 2 things
            >>
            >1 comunicate with the event mechanism ( 1- way )
            >2. comunicate over the idispatch interface ( 2- way event
            >comunication
            >possible in latebound way by just calling methods on Object pointers
            >that
            >are stored in property`s )
            >>
            >Both would be easy to implement with a litle help of COM
            >>
            >I wrote once a COM Server prog in VB.Net 2003 this way that needed
            >to
            >comunicate wit several VB6 , Delphi and a Clipper clients
            >>
            >HTH
            >>
            >michel
            >>
            >"sajin" <s...@iprlab.co mschreef in
            >berichtnews:11 76126933.695954 .96050@b75g2000 hsg.googlegroup s.com...
            >>
            Hi All..
            >>
            We are using VB .Net 2005 for implementing an API. API needs to
            generate events. For this client wants us to use Windows Callback
            (delegate implementation) . The intention of using Windows Callback
            is
            to generalise our API so that it can be compatible with any other
            language e.g. C++.
            >>
            Using normal delegates will not help us since delegates is a VB.Net
            feature and any other language cant make a use of it. Could please
            someone suggest us how to write a Windows Callback function in
            VB.Net?
            >>
            Any help will be appreciated :)
            >>
            Regards
            -AlertAdmin- Hide quoted text -
            >>
            >- Show quoted text -
            >>
            Hi Mich,
            >>
            Thanks for your explanation. But we didnt get the point that you were
            trying to explain. To just clarify what we want; There are 2 parts of
            the project API and Add-in. Currently both are written in VB.Net. API
            fire events to Add-in and Add-in in turn needs to capture it and
            perform some function.
            Now, the firing events from API should be so general that if at a
            later point, Add-in is wriiten in C++ then also API should be able to
            fire the events. And this will be possible only if we use Windows
            Callback function. The Windows Callback function will be written in
            Add-in and it will be fired from the API. So, we are stuck at this
            point of how to use Windows Callback in VB.Net
            >>
            Can you please post the code or atleast the snippet of COM server
            prog. Or any other point that can help us would be of great help.
            >>
            Regards
            -AlertAdmin- Hide quoted text -
            >>
            >- Show quoted text -
            >
            >

            Comment

            Working...