etDynamicCreation Sample Program

TeleTools

In multi-line programs it can become tedious to have to create multiple instances of components to handle each line.  The etDynamicCreation Sample Program shows how to dynamically create and activate components at runtime.  In other words, you can put just one etLine component on a page, for example, and then create multiple copies of that object for each line you wish to control.

Requirements
Using This Sample Program
Download this Sample Program 
How this Sample Program Works

Release Notes

Requirements

  • TeleTools v3.7 and above

  • Working TAPI Telephony device or voicemodem

Using This Sample Program

This sample is different from many of the others in that the sample for each development environment is slightly different.  Even if you don't "speak" the other languages, it may be worthwhile to look at each version to see different ways to use dynamic creation of components in your application.

The VB sample program uses TeleScope as a user interface.  Simply run the program, click on the "create" once for each  component you wish to create, and then double click on the etLine icons lined up down on the bottom of the form and select and enable a device using the TeleScope window that pops up.  You can do this for several lines.  Now make an incoming or outgoing call using TeleScope and watch the status line in the sample program change when the etLine OnCallBegin event fires!  Much more detailed information will display in the TeleScope log.

When you are through, click on the "destroy" button to delete each of your etLine controls one at a time (except the first one) and look at the code to see the proper way to destroy controls.

 

The VB.Net version of the program includes it's own user interface, though you should still double click on the etLine icons lined up on the bottom of the form to run TeleScope and watch what happens during calls.

We automatically create 4 etLine components for you at once when you press the "create" button.  Use the Line dropdown to select any of the 4 lines and then select a valid TAPI device from the device dropdown.  We automatically enable the device. If you had a 4 line dialogic card, you could enable all 4 lines simultaneously.  Now just place incoming calls to any activated line and watch the status line alert you and the CallerID information change.  If you like, you can use TeleScope to make outgoing calls or monitor more detailed call progress information with all of the TeleTools call progress events.

Download this Sample Program

For Use TeleTools v3.7

File

Purpose

EXE Ready to run!
Borland C++ 4,5,6 Source code and wave files
Borland Delphi 5,6,7 Source code and wave files
Visual Basic 5,6 Source code and wave files
Visual Basic .NET Source code and wave files
Tell us what you need? Click here and tell us what you need!

 

How this Sample Program Works

The code for this sample is very simple.  In VB 5 and 6, we use the "load" function in to dynamically create components at runtime like this:

etLineCount = etLineCount + 1
Load etLine(etLineCount - 1)
etLine(etLineCount - 1).Enabled = True

and to "UNLOAD" or destroy the component:

Unload etLine(etLineCount - 1)

This code, placed in a button, will create a new etLine component every time the button is pressed.  In your own code, you would just use a loop with an index variable to increment your count for however many lines you need.  Remember to enable the components and remember to destroy them when done!

Here is another way to do it that does not require any component to be dropped on the form.  You must have TeleTools installed in your components list first, so it can find the appropriate references.  In addition, you must go into the project options ( Project | Properties | Make Tab) and UNCHECK "Remove information about unused ActiveX controls".  Then just use this code:

NOTE: Make sure to use the right version for your component, etTT36.etLIne, etTT37.etLine, etTT40.etLine, etc.

General Section:

Option Explicit
Public WithEvents myetLine As etTT40.etLine

Form_Load or Event of your choice:

Set myetLine = Controls.Add("etTT40.etLine", "myetLine")
With myetLine
   .AboutSerialNumber = mySerialNumber
   .Visible = True
   .Enabled = True
   .TeleScopeVisible = True
End With

and in Form_Unload clean things up:

myetLine.DeviceActive = False
myetLine.Enabled = False
Controls.Remove myetLine

In VBA (Visual Basic For Applications) or VB, yet another way:

General Section:

Public WithEvents etLine1 As etTT37.etLine

Form_Load or Event of your choice:

Set etLine1 = New etTT37.etLine
etLine1.AboutSerialNumber = mySerialNumber
etLine1.Enabled = True

In Delphi the code would look like this:

NewetLine := TetLine.Create(Self);
NewetLine.Enabled := True;

and to destroy the component...

NewetLine.Destroy;

In C++ this is the code:

NewetLine = new TetLine((TComponent *) this);
NewetLine->Enabled = True;

delete NewetLine;

In VB.Net it looks like this:

etLine(i) = New AxetTT37.AxetLine()
Controls.Add(etLine(i)) 

Controls.Remove(etLine(i))
etLine(i).Dispose()

In VB.NET, you will need to do it this way if you want to create the components in the form_load event:

CType(Me.etLine(iLine), System.ComponentModel.ISupportInitialize).BeginInit()
     Controls.Add(etLine(iLine))
CType(Me.etLine(iLine), System.ComponentModel.ISupportInitialize).EndInit()

And to make programming easy and use one event handler called by multiple components, you can add this:

AddHandler etLine(i).OnCallerID, AddressOf etLine_OnCallerID

 

Be sure to look at the sourcecode and it's detailed help embedded in the source.  Let us know if you have any questions!

Control

Description

ButtonCreateLines

Dynamically creates etLine controls

ButtonDestroyLines Destroys the dynamically created controls
etLine0 The TeleTools etLine TAPI telephony control. We use etLine0 as a seed control from which we create the others dynamically at runtime

NOTE: Since there is great variety between versions, this is only a general indication of the Controls and events used in the program.  Download and view the source for the program or programs in the development environment of your choice.

Event Handler Routine

Description

etLine_OnOffering

TeleTools event signifying a new incoming call

etLine_OnCallBegin TeleTools event showing a new call has begun and offering a start time
etLine_OnCallEnd TeleTools event showing a call has ended and offering the ending time
etLine_OnCallerID TeleTools event showing CallerID information has changed and providing the name and number
etLine_OnRing TeleTools event showing that an incoming call is ringing and providing the ring count

 

Release Notes

August 15, 2003

Add VB.NET version, enhance Delphi version and make minor cosmetic changes to all versions.

July 1, 2002

First release