By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,693 Members | 1,132 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,693 IT Pros & Developers. It's quick & easy.

Plzzzzzzzzzzz Help for callback function

P: n/a
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

Apr 9 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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" <sa***@iprlab.comschreef in bericht
news:11*********************@b75g2000hsg.googlegro ups.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

Apr 9 '07 #2

P: n/a
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.comschreef in berichtnews:11*********************@b75g2000hsg.go oglegroups.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


Apr 10 '07 #3

P: n/a

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

http://groups.google.nl/group/micros...996d74d250974e
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" <sa***@iprlab.comschreef in bericht
news:11**********************@n76g2000hsh.googlegr oups.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.comschreef in
berichtnews:11*********************@b75g2000hsg.g ooglegroups.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


Apr 10 '07 #4

P: n/a
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


On Apr 10, 10:59 pm, "Michel Posseth [MCP]" <M...@posseth.comwrote:
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.comschreef in berichtnews:11**********************@n76g2000hsh.g ooglegroups.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.comschreef in
berichtnews:11*********************@b75g2000hsg.go oglegroups.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 -

Apr 11 '07 #5

P: n/a
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" <sa***@iprlab.comschreef in bericht
news:11**********************@b75g2000hsg.googlegr oups.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(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


On Apr 10, 10:59 pm, "Michel Posseth [MCP]" <M...@posseth.comwrote:
>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.comschreef in
berichtnews:11**********************@n76g2000hsh. googlegroups.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.comschreef in
berichtnews:11*********************@b75g2000hsg.g ooglegroups.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 -


Apr 11 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.