catching events
-
I create ATL component with a number of methods. Some of them run perform long operations, and I need send to client application status of this. How do I have to add event to my ATL and listen it in a client application ?
Hello Dudic, My advise is to create a separate thread in your COM Object to perform the long operations. As and when a change in status occurs in your COM object, you fire an event to your client app. There are several points you need to note about achieving the above mentioned design : 1. Your thread must be a COM thread. That is, it must call CoInitialize() on start up and call CoUninitialize() just before termination. 2. The event handler interface pointer of your client (which are passed to you when your client connects with your COM Object's connection points) must be marshalled to your COM Object. They -CANNOT- be passed to your thread by simple copying. I'm going to write an article on COM threading soon and I'll keep you posted when I do. Best Regards, Bio.
-
I create ATL component with a number of methods. Some of them run perform long operations, and I need send to client application status of this. How do I have to add event to my ATL and listen it in a client application ?
dudic wrote: I create ATL component with a number of methods. Some of them run perform long operations, and I need send to client application status of this. How do I have to add event to my ATL and listen it in a client application ? yeah Buddy, you have to implement IConnectionPoint Interface in you class to raise event. Follow these step-> 1.add a simpleATL object using Insert|newATlobject chose Simple Object and press NEXT you find the Property Sheet there #1 property sheet for name Give the name to you object say ObjectEvent. #2 Attribute Check the boc for IConnectionPoint interface. then press ok. you will see two interface for your class interface ObjectEvent dispinterface _IObjectEvent add method in _IObjectEvent thorough class wizard. like void MyEvent(); and implement this Connection point in the iObjectEvnt Interface. you can get option by right clicking on class of interface. and for notifying other user about event you got the Event in you Interface class like this FIRE_MyEvent() and by calling this function you can fire event that can be handle by clientapplication. dudic wrote: listen it in a client application sorry i don't have any knowledge about how to handle event in VC++ based application ,because i used to test application with VB. i hope any good programmer will help you in this matter ----------------------------- "I Think It Will Help" ----------------------------- Alok Gupta visit me at http://www.thisisalok.tk