Re: tapi3 and delphi
- From: "Matthias Moetje [MVP]" <moetje@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 1 Dec 2005 14:43:16 +0100
Huang,
this question has been asked several times here, but it
seems there is no Delphi expert around. TAPI3 provides
proper COM events, so the problem must be on the
Delphi side. I guess it would be a good idea to ask this
question in a Delphi group.
Best regards,
Matthias Moetje
-------------------------------------
TERASENS GmbH
Augustenstraße 24
80333 Munich, GERMANY
-------------------------------------
Fon: +49 89 143370-0
Fax: +49 89 143370-22
e-mail: moetje at terasens dot com
www: www.terasens.com
-------------------------------------
"Huang" <huangwensheng@xxxxxxxxx> wrote in message
news:1133420970.866549.280840@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> hi,
>
> When I program tapi3 in delphi 7 using the code below, I can make a
> outgoing call, but I can't catch any events. Has anybody face the same
> problem ?
>
> Wensheng
>
>
> unit Unit10;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
> Forms,
> Dialogs, TAPI3Lib_TLB, StdCtrls, ActiveX, ComObj, OleServer;
> {
> type
> TTapiEventsSink = class( TObject, IConnectionPointContainer, I)
> procedure TAPI1Event(ASender: TObject; TapiEvent: TOleEnum;
> const pEvent: IDispatch);
> end;
> }
> type
> TForm1 = class(TForm)
> ComboBox1: TComboBox;
> Button1: TButton;
> Button2: TButton;
> Edit1: TEdit;
> Button3: TButton;
> Edit2: TEdit;
> Button4: TButton;
> TAPI1: TTAPI;
> Memo1: TMemo;
> procedure FormCreate(Sender: TObject);
> procedure Button1Click(Sender: TObject);
> procedure Button2Click(Sender: TObject);
> procedure Button3Click(Sender: TObject);
> procedure TAPI1Event(ASender: TObject; TapiEvent: TOleEnum;
> const pEvent: IDispatch);
> private
> { Private declarations }
> public
> { Public declarations }
> tapi3 : ITTAPI;
> addr : ITAddress;
> media : ITMediaSupport;
> addrs : IEnumAddress;
> term : ITTerminal;
> terminalSupport : ITTerminalSupport;
> basicall :ITBasicCallControl;
> dir : TOleEnum;
>
> streamControl : ITStreamControl;
> enumStream : IEnumStream;
> stream : ITStream;
> mediatype : Integer;
> direct : TERMINAL_DIRECTION;
> lAddressType : Integer;
> bHold : Boolean;
>
> event : ITCallNotificationEvent;
> tapievent : ITTAPIEventNotification;
> unknown : IUnknown;
>
> end;
>
> const TAPI3_CALL_EVENTS =
> TE_CALLMEDIA OR
> TE_CALLNOTIFICATION OR
> TE_CALLSTATE;
> const
> TAPIMEDIATYPE_AUDIO = $8;
> TAPIMEDIATYPE_VEDIO = $8000;
> TAPIMEDIATYPE_DATEMODEM = $10;
> TAPIMEDIATYPE_G3FAX = $20;
> LINEADDRESSTYPE_PHONENUMBER = $00000001;
> EVENT_FILTER =
> TE_TAPIOBJECT OR
> TE_ADDRESS OR
> TE_CALLNOTIFICATION OR
> TE_CALLSTATE OR
> TE_CALLMEDIA OR
> TE_CALLHUB OR
> TE_CALLINFOCHANGE OR
> TE_PRIVATE OR
> TE_REQUEST OR
> TE_AGENT OR
> TE_AGENTSESSION OR
> TE_QOSEVENT OR
> TE_AGENTHANDLER OR
> TE_ACDGROUP OR
> TE_QUEUE OR
> TE_DIGITEVENT OR
> TE_GENERATEEVENT;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.dfm}
>
> procedure TForm1.FormCreate(Sender: TObject);
> var
> lwCeltFetched : Cardinal;
> cookievar : Integer;
> begin
> bHold := false;
>
> tapi1.Initialize;
> tapi1.Connect;
>
> { Select an address }
> // list address
> addrs := tapi1.DefaultInterface.EnumerateAddresses;
> //addrs := tapi3.EnumerateAddresses;
> while ( S_OK = addrs.Next(1,addr,lwCeltFetched) ) do
> begin
> ComboBox1.Items.Add(addr.AddressName);
> end;
>
> end;
>
> procedure TForm1.Button1Click(Sender: TObject);
> begin
>
> basicall.Disconnect(DC_NORMAL);
>
> end;
>
> procedure TForm1.Button2Click(Sender: TObject);
> var
> lwCeltFetched : Cardinal;
> iRes : Integer;
> i : Integer;
> hr : Integer;
>
> begin
>
> { Select an address }
> addrs.Reset;
> while ( S_OK = addrs.Next(1,addr,lwCeltFetched) ) do
> begin
> hr := addr.QueryInterface(IID_ITMediaSupport,media);
> if ( true = media.QueryMediaType(TAPIMEDIATYPE_AUDIO) ) then
> break;
> end;
>
>
> tapi1.EventFilter := EVENT_FILTER;
>
> tapi1.RegisterCallNotifications(addr,true,false,TAPIMEDIATYPE_AUDIO,1);
>
>
> end;
>
> procedure TForm1.Button3Click(Sender: TObject);
> var
> phonenum : array [0..30] of char;
> begin
> lAddressType := LINEADDRESSTYPE_PHONENUMBER;
> StrPCopy( phonenum, Edit1.Text );
> basicall :=
> addr.CreateCall(phonenum,lAddressType,TAPIMEDIATYPE_AUDIO);
> basicall.Connect(false);
>
>
> end;
>
>
>
> procedure TForm1.TAPI1Event(ASender: TObject; TapiEvent: TOleEnum;
> const pEvent: IDispatch);
> var
> callinfo : ITCallInfo;
> event : ITCallNotificationEvent;
> begin
> Memo1.Lines.Add('hi');
> Memo1.Refresh;
> case TapiEvent of
> TE_CALLNOTIFICATION :
> begin
> Memo1.Lines.Add('call notification');
> end;
> end;
>
> end;
>
.
- References:
- tapi3 and delphi
- From: Huang
- tapi3 and delphi
- Prev by Date: Re: Discador telefonico automatico con Tapi3
- Next by Date: Incomplete Call Parameters
- Previous by thread: tapi3 and delphi
- Next by thread: Re: Call Handling Problem
- Index(es):