ExceleTel Header Logo

 

menu_end_leftmenu_homemenu_aboutmenu_productsmenu_salesmenu_supportmenu_searchmenu_end_right

 

etQuickDial Sample Program Source Code for Delphi

' *******************************************************************
' To make this program compile on your machine, be sure to have
' the etLine component on your form and to click the "AboutLoadSerialnumber"
' property to install your serial number into the component. Then click on
' the enabled property to set it to true. You must compile this program with
' a purchased serial number or it will operate with reminder screens.
'
' We recommend that for learning, testing and debugging, you turn the "visible"
' property of the etLine component to TRUE. You will then be able to click on
' the component at any time and launch TeleScope which will be your view into
' everything going on in your program. Please read the help file sections about
' TeleScope, it may be the most valuable first advice we can provide to you.
' You may also place the line, "etLine1.TeleScopeActive = True" anywhere in your
' code where you want TeleScope to popup. It's a great idea to include a secret
' hotkey combination in your code to enable the TeleScope for your components so
' that you or your clients can email informative logs.
'
' Thank You, and remember to contact us for any assistance you may require.
'
' Copyright © 2003
' ExceleTel, Inc
' Raleigh, NC
' 919-233-2232
' www.exceletel.com
'
' ******************************************************************

const NL = #13 + #10; //insert a new line

var Form1: TForm1;


implementation


{$R *.DFM}

{------------------------------------------------------------------------------}
{ FormCreate
{------------------------------------------------------------------------------}
procedure TForm1.FormCreate(Sender: TObject);
begin
  //Enable all of the ExceleTel TeleTools controls before using them!
  etLine1.Enabled := True;
  // etPhone1.Enabled = True (if you were using these...)
  // etPlay1.Enabled = True
  // etRecord1.Enabled = True

  // Uses the etLine DeviceIdleDelay property to delay the OnIdle event from firing
  // for 2 seconds. This gives devices such as modems and Dialogic cards that need
  // time to reset between calls. Comment this line out and try quickly dialing and
  // hanging up calls and see if you get RESOURCE_UNAVAILABLE or other errors.

  etLine1.Device.IdleDelay := 2000;

  EditPhoneNumber.Text := etLine1.Call.PhoneNumber;
  ComboBoxDevice.Items := etLine1.Device.List;
  if ComboBoxDevice.Items.Count > 0 then
      ComboBoxDevice.Text := ComboBoxDevice.Items[0];
      ComboBoxDevice.ItemIndex := 0;
end;

{------------------------------------------------------------------------------}
{ CheckBoxActiveClick - Activate and Deactivate the TAPI Line device
{------------------------------------------------------------------------------}
procedure TForm1.CheckBoxActiveClick(Sender: TObject);
var sTemp: String;
begin
  if not CheckBoxActive.Checked then
    begin
      if etLine1.Device.Active then
        begin
          Memo1.Lines.Add('etLine1.Device.Active := False');
          etLine1.Device.Active := False;
          if not etLine1.Device.Active then
            begin
              ButtonDial.Enabled := False;
            end
          else
            begin
              Memo1.Lines.Add(#9 + 'Error = ' + etLine1.Error.Text);
              CheckBoxActive.Checked := True;
            end;
          end;
        end
      else
        begin
          if not etLine1.Device.Active then
            begin
              ButtonHangup.Enabled := False;
              Memo1.Lines.Add('etLine1.Device.Active := True');
              etLine1.Device.Active := True;
              if (not etLine1.Device.Active) and (etLine1.Error.Number = LINEERR_INVALMEDIAMODE) and
                (Pos('MODEM',UpperCase(etLine1.TAPI.TSP)) > 0) then
                begin
                etLine1.Privilege.None := True;
                etLine1.Device.Active := True;

                sTemp := 'TeleTools has detected that your device is a (' + etLine1.Device.Name +
                ') DATA modem and therefore has no voice capabilities.' + NL + NL +
                'TeleTools will now force a compatibility mode in order to allow you to ' +
                ' continue while greying out options your modem may not support.' + NL + NL +
                'This device will be able to:' + NL + NL + #9 + 'DIAL' + NL + NL +
                'If you think you have a voice modem, expected more functionality, ' +
                'or other programs provide more functionality with this modem, see the ' +
                'topic "Working with Modems" in the Appendix of the TeleTools help file.';

                Memo1.Lines.Add(sTemp);
                sTemp := sTemp + #0;
                Application.MessageBox(@sTemp[1], 'Limited Functionality Device', mb_OK);
              end;
            if etLine1.Device.Active then
              begin
                ButtonDial.Enabled := True;
              end
            else
              begin
                Memo1.Lines.Add(#9 + 'Error = ' + etLine1.Error.Text);
                CheckBoxActive.Checked := False;
              end;
           end;
        end;
end;

{------------------------------------------------------------------------------}
{ ComboBoxDeviceChange - Process device change, check for errors, set privileges
{------------------------------------------------------------------------------}
procedure TForm1.ComboBoxDeviceChange(Sender: TObject);
begin
  if etLine1.Device.Active then
    CheckBoxActive.Checked := False;
  Memo1.Lines.Add('etLine1.Device.ID := ' + IntToStr(ComboBoxDevice.ItemIndex));
  etLine1.Device.ID := ComboBoxDevice.ItemIndex;
  if etLine1.Error.Number <> 0 then
    Memo1.Lines.Add(#9 + 'Error = ' + etLine1.Error.Text)
  else
    begin
      etLine1.Privilege.Monitor := True;
      etLine1.Privilege.Owner := True;
  end;
end;

{------------------------------------------------------------------------------}
{ ButtonClearClick - Clear the memo box log
{------------------------------------------------------------------------------}
procedure TForm1.ButtonClearClick(Sender: TObject);
begin
  Memo1.Lines.Clear; //clear the log in the memo box for this application
end;

{------------------------------------------------------------------------------}
{ ButtonDialClick - Dial on the etLine device
{------------------------------------------------------------------------------}
procedure TForm1.ButtonDialClick(Sender: TObject);
begin
  etline1.Call.Handle := 0; // reset call handle to 0 to ensure a new call
  etLine1.Call.PhoneNumber := EditPhoneNumber.Text; // enter the phone number
  // This example uses no call parameters. If you wanted to change the defaults, for example
  // to tell the defice to use the second address of the line device, you would change the
  // parameters here like this:
  //
  // etLine1.Call.Parameters.Defaults := False
  // etLine1.Call.Parameters.AddressID := 1
  //
  // See the help file section etLine | Properties | Call | Parameters for more info

  Memo1.Lines.Add('Dialing [' + EditPhoneNumber.Text + ']');
  // This is where you dial a call. Rather than executing etLine1.CallDial and having to
  // check if an error was generated, we use the method as a simple function. By putting
  // it in an IF statement, we dial the phone and check to see if the result returned was
  // true of false. See the help file section "How Do I Do That | Make a Call"

  if etLine1.Call.Dial then
    begin
      ButtonDial.Enabled := False;
      ButtonHangup.Enabled := True;
    end
  else
    begin
      // this will cause the error to show twice in the log since we are using as simple OnError
      // event handler also
      Memo1.Lines.Add(#9 + 'Error Dialing = ' + etLine1.Error.Text);
      ButtonHangup.Click(); //Just in case the device didn't drop the call
    end;
end;

{------------------------------------------------------------------------------}
{ ButtonHangupClick - Hangup the call on the etLine device. The disconnected
{ state and the idle state are different. Just putting the handset down
{ may fire the OnDisconnected event, but you aren't done with the call
{ until you execute the hangup method. Methods like Call.Hangup and Call.Dial
{ return true or false, so can be used as here to combine two functions, dialing
{ or hanging up, and returning a true or false if the method was executed or not
{------------------------------------------------------------------------------}
procedure TForm1.ButtonHangupClick(Sender: TObject);
begin
  Memo1.Lines.Add('etLine.Hangup');
  if (etLine1.Call.Handle <> 0) and
    (etLine1.Call.State <> LINECALLSTATE_IDLE) Then
  If Not etLine1.Call.Hangup then
    Memo1.Lines.Add(#9 + 'This TSP Already hungup while calling this method');
end;

{------------------------------------------------------------------------------}
{ etLine1Offering
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Offering(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnOffering');
end;

{------------------------------------------------------------------------------}
{ etLine1Proceeding - the OnProceeding event has fired
{ NOTE: Only available on TeleTools Standard Edition and above
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Proceeding(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnProceeding');
end;

{------------------------------------------------------------------------------}
{ etLine1CallBegin - the OnCallBegin event has fired
{------------------------------------------------------------------------------}
procedure TForm1.etLine1CallBegin(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnCallBegin');
  Memo1.Lines.Add(#9 + 'Callhandle = ' + IntToStr(CallHandle));
  Memo1.Lines.Add(#9 + DateTimeToStr(etLine1.Call.Began));
end;

{------------------------------------------------------------------------------}
{ etLine1Dialtone - the OnDialtone event has fired
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Dialtone(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnDialtone');
end;

{------------------------------------------------------------------------------}
{ etLine1Dialing - the OnDialing event has fired
{ NOTE: Only available on TeleTools Standard Edition and above
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Dialing(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnDialing');
end;

{------------------------------------------------------------------------------}
{ etLine1Busy - the OnBusy event has fired. The phone is busy!
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Busy(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnBusy');
  Memo1.Lines.Add(#9 + etLine1.StringLINECALLSTATE(etLine1.Call.State));
  Memo1.Lines.Add(#9 + etLine1.StringLINEBUSYMODE(etLine1.Call.BusyMode));
  ButtonHangup.Click;
end;

{------------------------------------------------------------------------------}
{ etLine1CallerID - the OnCallerID event has fired
{ You would use the etLine.Call.CallerID.MaskNumber here to format the
{ number based on if the CallOrigin was Internal or External and other
{ factors. Use TeleScope and the Help File to learn more.
{------------------------------------------------------------------------------}
procedure TForm1.etLine1CallerID(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnCallerID');
  Memo1.Lines.Add(#9 + 'CallerID.Name = ' + etLine1.Call.CallerID.Name);
  Memo1.Lines.Add(#9 + 'CallerID.Number = ' + etLine1.Call.CallerID.Number);
end;

{------------------------------------------------------------------------------}
{ etLine1CalledID - the OnCalledID event has fired
{ NOTE: Only available on TeleTools Standard Edition and above
{
{ You would use the etLine.Call.CallerID.MaskNumber here to format the
{ number based on if the CallOrigin was Internal or External and other
{ factors. Use TeleScope and the Help File to learn more.
{------------------------------------------------------------------------------}
procedure TForm1.etLine1CalledID(Sender: TObject; CallHandle: Integer);
begin
  etLine1.Call.Handle := CallHandle;
  Memo1.Lines.Add('etLine1.OnCalledID');
  Memo1.Lines.Add(#9 + 'CalledID.Name = ' + etLine1.Call.CalledID.Name);
  Memo1.Lines.Add(#9 + 'CalledID.Number = ' + etLine1.Call.CalledID.Number);
end;

{------------------------------------------------------------------------------}
{ etLine1Connected - the OnConnected event has fired
{ NOTE: Modems report the connected state immediately after dialing the phone
{ Number. You may not really be connected!
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Connected(Sender: TObject; CallHandle: Integer);
begin
  // etLine1.Call.Handle := CallHandle;
  Memo1.Lines.Add('etLine1.OnConnected');
  Memo1.Lines.Add(#9 + DateTimeToStr(etLine1.Call.Connected));
  ButtonHangup.Enabled := True;

  // This is optional code to turn on the MonitorDigits capability if your device
  // supports it. You can delted from here to the end of the routine and delete
  // the OnDigitReceived event to simplify the program and not respond to DTMF

  if (etLine1.Address.Capabilities.CallFeatures and LINECALLFEATURE_MONITORDIGITS) <> 0 then
    etLine1.Call.MonitorDigits.Active := True;
  // Modems do not report LINECALLFEATURE_MONITORDIGITS correctly!
  // Use this method to check for modems
  if (Pos('MODEM',UpperCase(etLine1.TAPI.TSP)) > 0) then
    if (Not etLine1.Privilege.None) then
      begin
        // Using a voice modem
        etLine1.Call.MonitorDigits.Active := True;
      end
    else
      if (etLine1.Address.Capabilities.CallFeatures and LINECALLFEATURE_MONITORDIGITS) <> 0 then
       etLine1.Call.MonitorDigits.Active := True;
      // END of DTMF code
end;

{------------------------------------------------------------------------------}
{ etLine1ConnectedID - the OnConnectedID event has fired
{ NOTE: Only available on TeleTools Professional Edition and above
{------------------------------------------------------------------------------}
procedure TForm1.etLine1ConnectedID(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnConnectedID');
  Memo1.Lines.Add(#9 + 'ConnectedID.Name = ' + etLine1.Call.ConnectedID.Name);
  Memo1.Lines.Add(#9 + 'ConnectedID.Number = ' + etLine1.Call.ConnectedID.Number);
end;

{------------------------------------------------------------------------------}
{ etLine1Disconnected - the OnDisconnected event has fired
{ NOTE: Many modems do not report the remote party disconnect!
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Disconnected(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnDisconnected');
  Memo1.Lines.Add(#9 + DateTimeToStr(etLine1.Call.Disconnected));
  Memo1.Lines.Add(#9 + 'Call.DisconnectMode = ' +
  etLine1.StringLINEDISCONNECTMODE(etLine1.Call.DisconnectMode));
  ButtonHangup.Click;
end;

{------------------------------------------------------------------------------}
{ etLine1CallEnd - the OnCallEnd event has fired
{------------------------------------------------------------------------------}
procedure TForm1.etLine1CallEnd(Sender: TObject; CallHandle: Integer);
begin
  etLine1.Call.Handle := Callhandle;
  Memo1.Lines.Add('etLine1.OnCallEnd');
  Memo1.Lines.Add(#9 + DateTimeToStr(etLine1.Call.Ended));
end;

{------------------------------------------------------------------------------}
{ etLine1Idle - Call is in the idle state
{ NOTE: The device is not idle, just the call. Some devices need a second
{ or more to reset between calls. Use the etLine.Device.IdleDelay property
{ to set a delay so that the device is actually ready when the OnIdle event
{ for the call is fired
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Idle(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnIdle');
  ButtonHangup.Enabled := False;
  ButtonDial.Enabled := True;
end;

{------------------------------------------------------------------------------}
{ etLine1RedirectingID
{ NOTE: Only available on TeleTools Professional Edition and above
{------------------------------------------------------------------------------}
procedure TForm1.etLine1RedirectingID(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnRedirectingID');
  Memo1.Lines.Add(#9 + 'RedirectingIDName = ' + etLine1.Call.RedirectingID.Name);
  Memo1.Lines.Add(#9 + 'RedirectingIDNumber = ' + etLine1.Call.RedirectingID.Number);
end;

{------------------------------------------------------------------------------}
{ etLine1RedirectionID
{ NOTE: Only available on TeleTools Professional Edition and above
{------------------------------------------------------------------------------}
procedure TForm1.etLine1RedirectionID(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnRedirectionID');
  Memo1.Lines.Add(#9 + 'RedirectionIDName = ' + etLine1.Call.RedirectionID.Name);
  Memo1.Lines.Add(#9 + 'RedirectionIDNumber = ' + etLine1.Call.RedirectionID.Number);
end;

{------------------------------------------------------------------------------}
{ etLine1Ring - The incoming etLin1 OnRing event has fired, someone is calling
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Ring(Sender: TObject; Count, RingMode: Integer);
begin
  Memo1.Lines.Add('etLine1.OnRing [' + IntToStr(Count) + ', ' + IntToStr(RingMode) + ']');
end;

{------------------------------------------------------------------------------}
{ etLine1RingBack - The etLine OnRingBack event has fired, your call is ringing
{------------------------------------------------------------------------------}
procedure TForm1.etLine1RingBack(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnRingBack');
end;

{------------------------------------------------------------------------------}
{ etLine1SpecialInfo
{ NOTE: Only available on TeleTools Standard Edition and above
{------------------------------------------------------------------------------}
procedure TForm1.etLine1SpecialInfo(Sender: TObject; CallHandle: Integer);
begin
  Memo1.Lines.Add('etLine1.OnSpecialInfo');
  Memo1.Lines.Add(#9 + 'etLine1.Call.SpecialInfo = ' +
  etLine1.StringLINESPECIALINFO(etLine1.Call.SpecialInfo));
end;

{------------------------------------------------------------------------------}
{ etLine1DigitRecieved - event to display DTMF digits
{ NOTE - Only available on TeleTools Standard Edition and above
{------------------------------------------------------------------------------}
procedure TForm1.etLine1DigitReceived(Sender: TObject; CallHandle: Integer;
      Digit: Char; Tag: Integer);
begin
  Memo1.Lines.Add('etLine1.OnDigitReceived [' + Digit + ']');
end;

{------------------------------------------------------------------------------}
{ etLine1Error
{ You can process your own errors in your routines or use the etLineOnError event
{ to process them for you
{------------------------------------------------------------------------------}
procedure TForm1.etLine1Error(Sender: TObject);
begin
  Memo1.Lines.Add('etLine1.OnError');
  Memo1.Lines.Add(#9 + 'etLine1.Error = ' + etLine1.Error.Text);
end;

{------------------------------------------------------------------------------}
{ Enable TeleScope Tool
{ TeleScope is an amazing prototying, testing, debugging, and diagnostic tool
{ Click the TeleScope button and watch what happens in it's logs. Place and receive
{ calls and a LOT more. See the help file section "Using TeleScope"
{------------------------------------------------------------------------------}
procedure TForm1.ButtonTeleScopeClick(Sender: TObject);
begin
  etLine1.TeleScope.Visible := TRUE;
  Memo1.Lines.Add('etLine.TeleScope.Visible = True');
end;

{------------------------------------------------------------------------------}
{ Display the device configuration screen for the TAPI hardware.
{ This is tied to the hardware manufacturer's Terminal Service Provider
{ or driver, also known as a TSP
{------------------------------------------------------------------------------}
procedure TForm1.ButtonLineConfigClick(Sender: TObject);
begin
  etLine1.Device.Configure
end;

{------------------------------------------------------------------------------}
{ Info Box
{------------------------------------------------------------------------------}
procedure TForm1.BitBtnInfoClick(Sender: TObject);
begin
  ShowMessage(' etQuickDial Sample Program' + NL + NL + 'Copyright(c) 2003 ExceleTel Inc.'
  + NL + NL + ' www.exceletel.com');
end;

{------------------------------------------------------------------------------}
{ FormClose
{------------------------------------------------------------------------------}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  // Close the etLine control when closing the form
  // We would have to close the wave device here if using etPlay and/or etRecord anywhere
  // before hanging up or deactivating the line device. This code can appear in the following
  // places to make sure the devices are deactivated, CommandHangup_Click, etLine1_OnDisconnected,
  // etLine1_OnIdle and Form_Unload
  // Decide here if you need to hangup the call since some devices will hangup when the
  // control is deactivated and some will keep the call active. You may want to not interrupt
  // a call if the application is closed or you may want to ensure that the call is terminated.
  // Close the etLine control when closing the form.

  etLine1.Device.Active := False;
end;

end.

 

 
 


Copyright © 1997-2007 ExceleTel Inc. All rights reserved. Friday August 17, 2007 11:05:24 AM

Contact Us