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(ByVal 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
"InvokeMethod" with the argument as object of addin
Dim obj As New Addin
Dim objApI As New API
objApI.InvokeMethod(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
Well here is the link to a small COM example i once showed in this
newsgroup
http://groups.google.nl/group/microsoft.public.dotnet.languages.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/library/d186xcf0(vs.80).aspx
regards
Michel
"sajin" <
[email protected]> schreef in
bericht
On Apr 10, 12:44 am, "Michel Posseth [MCP]" <
[email protected]>
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
"sajin" <
[email protected]> schreef in
berichtnews:
[email protected]...
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 -
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 -