Capturing Events
-
Hi, I have a method the fires an event. But I have not been able to find the way to capture the event in VC++. I can get this event through VB but I need it in VC. Please help. Thanks in advance.
-
Hi, I have a method the fires an event. But I have not been able to find the way to capture the event in VC++. I can get this event through VB but I need it in VC. Please help. Thanks in advance.
-
WaitForsingleObject http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/waitforsingleobject.asp[^] Eric Premature optimization is the root of all evil
Thanks Eric. Wasn't what I was look 4 but appreicated the help.
-
Thanks Eric. Wasn't what I was look 4 but appreicated the help.
Hello w_logan, What you want to develop is an "Event Sink". If you are using ATL, create a class that inherits from IDispEventImpl. You will also need to include the BEGIN_SINK_MAP(), SINK_ENTRY_EX() and END_SINK_MAP() macros. Of course, your class will have to implement the event function itself. The great thing about the sink map macros is that you choose only those events that you want to supply handlers for. You do not need to implement handlers for all the events. An alternative to using the above-mentioned ATL constructs is to use my TEventHandler class. Please read my article : "Understanding COM Event Handling" (http://www.codeproject.com/com/TEventHandler.asp[^]) - Bio.
-
Hello w_logan, What you want to develop is an "Event Sink". If you are using ATL, create a class that inherits from IDispEventImpl. You will also need to include the BEGIN_SINK_MAP(), SINK_ENTRY_EX() and END_SINK_MAP() macros. Of course, your class will have to implement the event function itself. The great thing about the sink map macros is that you choose only those events that you want to supply handlers for. You do not need to implement handlers for all the events. An alternative to using the above-mentioned ATL constructs is to use my TEventHandler class. Please read my article : "Understanding COM Event Handling" (http://www.codeproject.com/com/TEventHandler.asp[^]) - Bio.
Thanks Bio. I had already read the article when I was doing my research. It was a great article. I had initially intended to use "Event Sink" to solve my problem but I work around it by another mean. Actually, I had a COM DLL with multiple objects within it. But I had only expose the main object class. My problem arise when one of my internal object needs to fire a event to the app using my DLL. As only the main interface is expose, the internal object can't fire the event direct to the app. I was trying use the main object to sink the event and fire it again. But I never really got the way for doing the sink coding properly. Nonetheless, I worked around it by send the point to the main object inwards to the internal object and use this pointer to fire the event. It may not be the proper way to solve the problem but it solve my problem for now. Nonetheless, thanks for the help again. (If you remember, you had help this fellow Singaporean on several other occasion.) Cheers -- modified at 22:09 Tuesday 22nd November, 2005
-
Thanks Bio. I had already read the article when I was doing my research. It was a great article. I had initially intended to use "Event Sink" to solve my problem but I work around it by another mean. Actually, I had a COM DLL with multiple objects within it. But I had only expose the main object class. My problem arise when one of my internal object needs to fire a event to the app using my DLL. As only the main interface is expose, the internal object can't fire the event direct to the app. I was trying use the main object to sink the event and fire it again. But I never really got the way for doing the sink coding properly. Nonetheless, I worked around it by send the point to the main object inwards to the internal object and use this pointer to fire the event. It may not be the proper way to solve the problem but it solve my problem for now. Nonetheless, thanks for the help again. (If you remember, you had help this fellow Singaporean on several other occasion.) Cheers -- modified at 22:09 Tuesday 22nd November, 2005
Hello w_logan, Yes, I remember you. We had corresponded som months ago I believe. How are you ? I hope you're doing well. Just a few comments : >> Actually, I had a COM DLL with multiple objects within it. But I had only expose the main object class. My problem arise when one of my internal object needs to fire a event to the app using my DLL. As only the main interface is expose, the internal object can't fire the event direct to the app. Comment : you may want to re-think about the design of your interfaces. Since the internal object needs to fire an event to your app, this may signal a need for the internal object's interface to be exposed to the app directly. On the other hand, if the internal object is meant to be internal afterall, then its events should rightfully be handled internally as well. The main object should be the handler for the event and it is a completely separate matter whether or not this main object ought to further "relay the message" to the app. >> I was trying use the main object to sink the event and fire it again. But I never really got the way for doing the sink coding properly. Comment : there are many ways to connect sinks with sources I guess. Just be careul about inter-thread event firing which will require marshaling. However, if everything happens on one thread, marshaling may not be so important. >> Nonetheless, I worked around it by send the point to the main object inwards to the internal object and use this pointer to fire the event. It may not be the proper way to solve the problem but it solve my problem for now. Comment : again, be careful about directly passing interface pointers here and there espacially across threads. Marshaling may be required. - Bio.
-
Hello w_logan, Yes, I remember you. We had corresponded som months ago I believe. How are you ? I hope you're doing well. Just a few comments : >> Actually, I had a COM DLL with multiple objects within it. But I had only expose the main object class. My problem arise when one of my internal object needs to fire a event to the app using my DLL. As only the main interface is expose, the internal object can't fire the event direct to the app. Comment : you may want to re-think about the design of your interfaces. Since the internal object needs to fire an event to your app, this may signal a need for the internal object's interface to be exposed to the app directly. On the other hand, if the internal object is meant to be internal afterall, then its events should rightfully be handled internally as well. The main object should be the handler for the event and it is a completely separate matter whether or not this main object ought to further "relay the message" to the app. >> I was trying use the main object to sink the event and fire it again. But I never really got the way for doing the sink coding properly. Comment : there are many ways to connect sinks with sources I guess. Just be careul about inter-thread event firing which will require marshaling. However, if everything happens on one thread, marshaling may not be so important. >> Nonetheless, I worked around it by send the point to the main object inwards to the internal object and use this pointer to fire the event. It may not be the proper way to solve the problem but it solve my problem for now. Comment : again, be careful about directly passing interface pointers here and there espacially across threads. Marshaling may be required. - Bio.
Lim Bio Liong wrote:
- Bio.
Hai Sir, I am waiting for an article on
IDispEventImpl
from your side :)..."Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
-
Lim Bio Liong wrote:
- Bio.
Hai Sir, I am waiting for an article on
IDispEventImpl
from your side :)..."Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV
Hello Alok ! How are you dear friend ? Enthusiastic as usual. It's very contagious :-) Yes, it'd be great if there's an in-depth dissertation on ATL's IDispEventImpl. Especially one that can show how to use it in MFC apps. I'll see if I can get some time on this. But how about yourself, Alok ? Would very much like to see you contribute another winner ! Best Regards, Bio.
-
Hello Alok ! How are you dear friend ? Enthusiastic as usual. It's very contagious :-) Yes, it'd be great if there's an in-depth dissertation on ATL's IDispEventImpl. Especially one that can show how to use it in MFC apps. I'll see if I can get some time on this. But how about yourself, Alok ? Would very much like to see you contribute another winner ! Best Regards, Bio.
Lim Bio Liong wrote:
How are you dear friend ? Enthusiastic as usual. It's very contagious
Ohh I am Alright Sir!.. As Usual :)..
Lim Bio Liong wrote:
Yes, it'd be great if there's an in-depth dissertation on ATL's IDispEventImpl. Especially one that can show how to use it in MFC apps. I'll see if I can get some time on this.
Thats would be Great :)... if you find some time for that!
Lim Bio Liong wrote:
But how about yourself, Alok ? Would very much like to see you contribute another winner !
Thats so nice of you, Sir!...But I am still in learning phase ... but as always its requires your help to get started :)...
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV