Using OnContactStatusChange in Delphi Code interacting with Microsoft Communicator 2007

429 Views Asked by At

Here's what I am trying to do. I want to be notified when a contact on my list changes status in Microsoft Communicator 2007. I'm running Delphi XE with Windows 7.

In my form create, I've created the communicator object, and loaded my contact list into a TListBox. I saw in CommunicatorAPI_TLB, that there is a method called:

  DMessengerEvents = dispinterface
...
    procedure OnContactStatusChange (const pMContact: IDispatch; mStatus: MISTATUS); dispid 1030;

I think this is the one that I want to use. How would I go about integrating this in my code?

{ Create the communicator object, it's already up and running }
COMMUNICATOR := CoMessenger.Create;

{ Load my contacts into a listbox; do NOT use Hard Typecasts }
Contacts := COMMUNICATOR.MyContacts As IMessengerContacts;

For ContactIndex := 0 To (Contacts.Count - 1) Do Begin

  Application.ProcessMessages;

  Contact := (Contacts.Item (ContactIndex) As IMessengerContact);

  { Add the contact to the list }
  lstContacts.AddItem (Contact.FriendlyName, Nil);

 End; { For }
0

There are 0 best solutions below