`
Windows API: Handling events from COM in OLE class 2002-11-03 -- Jim Kane Newsgroups: softvelocity.products.c55ee The type library you sent me indicates the com object generates an event. Cw does not natively support events used in conjunction with interfaces. However I wrote an article for cw mag that included my conptcl (connection point class) that does this in a thread-safe manor. The iid for the one and only event interface according to ole view is: IID:Icti32Events group !verify I copied correctly data1 ulong(0F1a9c677H) data2 ushort(03c8bH) data3 ushort(04812H) data4 string('<0b2H><0dbH><0dcH><02bH><0beH><080H><0acH><0aaH>') end to use my class and receive the event, create a window with an acceptloop. I'll call the window structure eventwindow. Call my conptcl init method like this in the event:openwindow: event:oleevent equate(9ABH) !arbitrary uniqueString equate('cticomobject') !arbitrary parametercount long eventid long parameterarray like(vartype),dim(15) !set up to connect for events later if SELF.ConPtCl.init(EventWindow, event:oleevent, thread(), uniquestring) then message('Error cant get events.') post(event:closewindow) end !lpinterface is the address of the interface you have been calling !we use that interfaces queryinterface() method to ask about events !the connection point interfaces we get back from queryinteface allow us to register to receive the events. if SELF.conptcl.connect(SELF.lpInterface, address(IID:Icti32Events)) then SELF.TakeError('connecting to cti object failed - no events') post(event:closewindow) end in event:closewindow conptcl.unadvise() in event:oleevent loop if SELF.ConptCl.GetNextEvent(EventId, parametercount, Address(parameterArray)) then break. !eventid will always be 1 and parameter count 0. parameterarray is unused !display/process the event yourclass.gotevent() end now your class gets called when ever the event fires. I thought It was odd that they dont pass the the id to tell you which line but for what ever reason according to ole view they do not. I suspect you should only call setcallback for one line if you are relying on events. Jim Kane ddock" Printed November 23, 2024, 8:23 pm This article has been viewed/printed 35206 times. Google search has resulted in 45 hits on this article since January 25, 2004. |