` Handling events from COM in OLE class (Jim Kane) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

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" wrote in message news:3dc55e5b$1@news.softvelocity.com... > Well one of the options when starting it is to create a log, so I did that. > Here's a clip from it: > > 11-03 9:27:49.150 Received Event on device 1 - Event: 134 > 11-03 9:27:49.150 dxxxB1C4: EVENT Ring. > 11-03 9:27:49.150 Fired callback for dxxxB1C4 > > So it does detect a ring and 'fire a callback' ... If I knew how to trap > either event, the ring detect or firing the callback, I could do I what I > need to but I don't know how to do that. The parameters I stated earlier are > the only ones I can pass ... no place to hand it the address of a procedure > to handle the callback. > > Ideas? > > "John E. Christ III" wrote in message > news:3dc54ee3$1@news.softvelocity.com... > > > I don't know how the connection between the event firing > > > and the callback routine is made. > > > > I would expect that you would tell it where to find your callback > procedure, > > and then it would call that procedure when the event occurs. But that's > > just a guess based on what you've said. > > > > John > > > > > >


Today is April 27, 2024, 11:29 am
This article has been viewed 35107 times.
Google search has resulted in 45 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: