|
i want to develop window in VC++ as a COM component and thene . use this component in .NET environment in C# client to put..control over that window..
how to do that..i wanna know..?
sam
|
|
|
|
|
You can import any COM dll into .NET and the framework will generate a class you can use to call it's methods. Seems lie a pain tho, what does C++/COM give you ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello Everyone,
well I wanted to know how we can change the layout of the keyboard so that we can take input in Urdu language. and Actually I wanna take the input in the dataGridView in a Windows Application in C# 2.0
thanks in advance
Rocky
|
|
|
|
|
U have to install the urdu layout of your keyboard
then install the phonetic keyboard layout (only for your own convenience)
then u have to set your culture at design time or at runtime
and when u run your application u have to select urdu as a keyboard layout
that's all
|
|
|
|
|
OK that looks quiet helpful but can u plz tell me how we set the culture at design time or at runtime via a code example preferably
thanks a bundle
|
|
|
|
|
First in your form's class constructor write this
System.Threading.Thread.CurrentThread.CurrentCulture = new
System.Globalization.CultureInfo("ur-PK");
System.Threading.Thread.CurrentThread.CurrentUICulture = new
System.Globalization.CultureInfo("ur-PK");
actually when u enter any character of any other language .net creates a new resource file for it
u just write the above lines in your code and then run the application or at design time switch your keyboard layout to urdu and type
that's all
|
|
|
|
|
thanks a lot that really is alot of help,
|
|
|
|
|
Respected Sir, do u have a simple program of Urdu listbox or urdu datagrid or urdu on listviewer
using vb.net
plz send me at sa.gdagwadar@gmail.com
Love to Every One
|
|
|
|
|
|
Ok, I have a treeview and it has the following items in it.
Menu 1
Sub menu 1
Then I call a function to write the items to a file.
But when I open the file it shows
Menu 1
Menu 1
Sub menu 1
Anyone know why it is creating the other Menu item?
Here are the functions.
menu += WriteMenu(menu, treeView1);
string WriteMenu(string menu, TreeView treeView) {
foreach(TreeViewMenuItem menuItem in treeView.Nodes) {
if(menuItem.Nodes.Count > 0) {
menu += menuItem.Text + "\n";
menu += WriteSubMenu(menu, menuItem);
}
else {
menu += menuItem.Text + "\n";
}
}
return menu;
}
string WriteSubMenu(string menu, TreeViewMenuItem menuItem) {
foreach(TreeViewMenuItem subItem in menuItem.Nodes) {
if(subItem.Nodes.Count > 0) {
menu += subItem.Text + "\n";
menu += WriteSubMenu(menu, subItem);
}
else {
menu += subItem.Text + "\n";
}
}
return menu;
}
-- modified at 20:47 Monday 4th June, 2007
|
|
|
|
|
Do u have any root node set to the tree view?
Regards,
Murali
|
|
|
|
|
This is giving me a real headache, I hope someone out there can help me.
Basically what I have is a text based adventure that takes input from the user.
for example...
string input;
Console.WriteLine("Where do you want to go?");
input = Console.ReadLine();
if ((input = "north") || (input = "North") || (input = "n") || (input = "N")
{
if ((y - 1) < 0)
Console.WriteLine(You can't move any farther North");
else
y = y - 1;
}
the bit that I want to change is where I check the input vs 4 values, north, North, n, and N.
Is there any shorter way of doing this, say checking it for letters and ignoring case sensitivity.
I suppose I could trim off the first letter, but then people could put anything in then like, nowhere, and they end up going north.
Thanks for your help ahead of time.
|
|
|
|
|
hi,
you could insert
input=input.ToLower();
and forget about uppercase.
|
|
|
|
|
Thanks a bunch, that helps loads. =)
|
|
|
|
|
Another option is String.Compare(s1, s2, true), where the true indicates to ignore case.
|
|
|
|
|
you can turn the whole position of the string to upper or lower case:
String str = "aBcD";
str = str.ToUpper();
if(str == "ABCD")
{
// Bla Bla Bla
}
when the IP reaches the IF check, it alwayse will enter to // Bla Bla Bla
|
|
|
|
|
I'll have a column name such as "Effective Date" and when I try to access it with a DataReader and then view the name with either the SchemaTable or DataReader.GetName(n) It'll return "Eff# Date." My question is why is the field name being shortened?
-Steven Hicks CPACodeProjectAddict
|
|
|
|
|
hi
i'm developing a software using c# that detects the dialed digits and the status(sp when connected and desconnected) of a call that is made by a handset attached to the modem.
i have developed some code but it doesn't work.please someone help me it's urgent.
i connected the main line to one of the modems telephone jack and the handset with the other jack and the computer is connected using the serial port and then
here is the code for status of the call
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using TAPI3Lib;
namespace tapi3call_status
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
public TAPIClass tapiobject;
private ITAddress[] ia = new TAPI3Lib.ITAddress[10];
uint lines;
int line;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label3;
public System.Windows.Forms.TextBox textBox2;
public callstatus cs = new callstatus();
private System.Windows.Forms.ListBox listBox1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public class CLineDevice
{
public string d_Name;
public int d_ID;
public override string ToString()
{
return d_Name;
}
}
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
initializetapi3();
}
//
// TODO: Add any constructor code after InitializeComponent call
//
void initializetapi3()
{
tapiobject = new TAPIClass();
tapiobject.Initialize();
IEnumAddress ea = tapiobject.EnumerateAddresses();
ITAddress ln;
cs = new callstatus();
cs.addtolist = new callstatus.listshow(this.status);
tapiobject.ITTAPIEventNotification_Event_Event += new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cs.Event);
uint arg3 = 0;
lines = 0;
for (int i = 0; i < 10; i++)
{
ea.Next(1, out ln, ref arg3);
ia[i] = ln;
if (ln != null)
{
comboBox1.Items.Add(ia[i].AddressName);
lines++;
}
else
break;
}
tapiobject.EventFilter = (int)(TAPI_EVENT.TE_CALLSTATE);
}
public void status(string str)
{
listBox1.Items.Add(str);
}
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
tapiobject.Shutdown();
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 80);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Call Status";
//
// button1
//
this.button1.Location = new System.Drawing.Point(184, 136);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 2;
this.button1.Text = "clear status";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 24);
this.label2.TabIndex = 3;
this.label2.Text = "line devices";
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(120, 16);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(224, 21);
this.comboBox1.TabIndex = 4;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 208);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 24);
this.label3.TabIndex = 5;
this.label3.Text = "Call Duration";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(120, 208);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(88, 20);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "0.0";
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(120, 72);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(192, 56);
this.listBox1.TabIndex = 7;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 254);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
line = comboBox1.SelectedIndex;
}
}
public class callstatus : TAPI3Lib.ITTAPIEventNotification
{
public StopWatch sw = new StopWatch();
public delegate void listshow(string str);
public listshow addtolist;
public void Event(TAPI3Lib.TAPI_EVENT te, object eobj)
{
Form1 fm = new Form1();
if (te == TAPI3Lib.TAPI_EVENT.TE_CALLSTATE)
{
TAPI3Lib.ITCallStateEvent a = (TAPI3Lib.ITCallStateEvent)eobj;
TAPI3Lib.ITCallInfo b = a.Call;
switch (b.CallState)
{
case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
addtolist("dialing");
break;
case TAPI3Lib.CALL_STATE.CS_CONNECTED:
addtolist("Connected");
sw.Start();
fm.textBox2.Text = "0";
break;
case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
addtolist("Disconnected");
sw.Stop();
fm.textBox2.Text = sw.GetElapsedTimeMinutes().ToString();
break;
case TAPI3Lib.CALL_STATE.CS_OFFERING:
addtolist("A party wants to communicate with you!");
break;
case TAPI3Lib.CALL_STATE.CS_IDLE:
addtolist("Call is created!");
break;
}
}
}
public class StopWatch
{
private DateTime startTime;
private DateTime stopTime;
private bool running = false;
public void Start()
{
this.startTime = DateTime.Now;
this.running = true;
}
public void Stop()
{
this.stopTime = DateTime.Now;
this.running = false;
}
// elaspsed time in minutes
public double GetElapsedTimeMinutes()
{
TimeSpan interval;
if (running)
interval = DateTime.Now - startTime;
else
interval = stopTime - startTime;
return interval.TotalMinutes;
}
// elaspsed time in seconds
public double GetElapsedTimeSecs()
{
TimeSpan interval;
if (running)
interval = DateTime.Now - startTime;
else
interval = stopTime - startTime;
return interval.TotalSeconds;
}
}
}
}
and the code for detecting the dialed number
#define Win32
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using TAPI3Lib;
//using TERMMGRLib;
using System.Runtime.InteropServices;
//
using System.Threading;
using System.Data;
namespace tonedetection
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private System.Windows.Forms.TextBox dtmf;
public digitdetect dd = new digitdetect();
//public AxTAPIEXLib.AxTAPIExCtl tapi;
public TAPI3Lib.TAPIClass tapi;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
#region Windows Form Designer generated code
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
Initializetonemonit();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
public void Initializetonemonit()
{
try
{
tapi = new TAPIClass();
tapi.Initialize();
dd = new digitdetect();
dd.tapi_tonemonit();
tapi.ITTAPIEventNotification_Event_Event+= new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(dd.tapi_event);
//tapi.EventFilter=(int)(TAPI_EVENT.TE_TONEEVENT);
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.dtmf = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// dtmf
//
this.dtmf.BackColor = System.Drawing.SystemColors.HighlightText;
this.dtmf.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dtmf.Location = new System.Drawing.Point(40, 104);
this.dtmf.Name = "dtmf";
this.dtmf.ReadOnly = true;
this.dtmf.Size = new System.Drawing.Size(216, 26);
this.dtmf.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(392, 198);
this.Controls.Add(this.dtmf);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private void Form1_Load(object sender, EventArgs e)
{
}
/*
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
*/
///
/// The main entry point for the application.
///
}
}
public class digitdetect
{
//MonitorTones_Add 1, 80, 697, 1209, 0 ' "1"
//.MonitorTones_Add 2, 80, 697, 1336, 0 ' "2"
//.MonitorTones_Add 3, 80, 697, 1477, 0 ' "3"
//.MonitorTones_Add 4, 80, 770, 1209, 0 ' "4"
//.MonitorTones_Add 5, 80, 770, 1336, 0 ' "5"
//.MonitorTones_Add 6, 80, 770, 1477, 0 ' "6"
//.MonitorTones_Add 7, 80, 852, 1209, 0 ' "7"
//.MonitorTones_Add 8, 80, 852, 1336, 0 ' "8"
//.MonitorTones_Add 9, 80, 852, 1477, 0 ' "9"
//.MonitorTones_Add 10, 80, 941, 1209, 0 ' "*"
//.MonitorTones_Add 0, 80, 941, 1336, 0 ' "0"
//.MonitorTones_Add 12, 80, 941, 1477, 0 ' "#"
//************
//currCall.MonitorTones_Add(BUSY_ID, BusyTone.Duration, BusyTone.FirstFreq, BusyTone.SecondFreq, 0);
//*********
//Function MonitorTones_Add(
//AppSpecific As Long,
//Duration As Long,
//Frequency1 As Long, Frequency2 As Long, Frequency3 As Long ) As Boolean
//*************************
TAPI3Lib.TAPI_DETECTTONE currentcal_0;
TAPI3Lib.TAPI_DETECTTONE currentcal_1;
TAPI3Lib.TAPI_DETECTTONE currentcal_2;
TAPI3Lib.TAPI_DETECTTONE currentcal_3;
TAPI3Lib.TAPI_DETECTTONE currentcal_4;
TAPI3Lib.TAPI_DETECTTONE currentcal_5;
TAPI3Lib.TAPI_DETECTTONE currentcal_6;
TAPI3Lib.TAPI_DETECTTONE currentcal_7;
TAPI3Lib.TAPI_DETECTTONE currentcal_8;
TAPI3Lib.TAPI_DETECTTONE currentcal_9;
TAPI3Lib.TAPI_DETECTTONE currentcal_10;
TAPI3Lib.TAPI_DETECTTONE currentcal_11;
//public TAPIEXLib.ITAPICall currentcall;
public void tapi_tonemonit()
{
currentcal_0.dwAppSpecific=1;
currentcal_0.dwDuration=80;
currentcal_0.dwFrequency1=941;
currentcal_0.dwFrequency2=1336;
currentcal_0.dwFrequency3=0;
currentcal_1.dwAppSpecific=1;
currentcal_1.dwDuration=80;
currentcal_1.dwFrequency1=697;
currentcal_1.dwFrequency2=1209;
currentcal_1.dwFrequency3=0;
currentcal_2.dwAppSpecific=1;
currentcal_2.dwDuration=80;
currentcal_2.dwFrequency1=697;
currentcal_2.dwFrequency2=1336;
currentcal_2.dwFrequency3=0;
currentcal_3.dwAppSpecific=1;
currentcal_3.dwDuration=80;
currentcal_3.dwFrequency1=697;
currentcal_3.dwFrequency2=1447;
currentcal_3.dwFrequency3=0;
currentcal_4.dwAppSpecific=1;
currentcal_4.dwDuration=80;
currentcal_4.dwFrequency1=770;
currentcal_4.dwFrequency2=1209;
currentcal_4.dwFrequency3=0;
currentcal_5.dwAppSpecific=1;
currentcal_5.dwDuration=80;
currentcal_5.dwFrequency1=770;
currentcal_5.dwFrequency2=1336;
currentcal_5.dwFrequency3=0;
currentcal_6.dwAppSpecific=1;
currentcal_6.dwDuration=80;
currentcal_6.dwFrequency1=770;
currentcal_6.dwFrequency2=1447;
currentcal_6.dwFrequency3=0;
currentcal_7.dwAppSpecific=1;
currentcal_7.dwDuration=80;
currentcal_7.dwFrequency1=852;
currentcal_7.dwFrequency2=1209;
currentcal_7.dwFrequency3=0;
currentcal_8.dwAppSpecific=1;
currentcal_8.dwDuration=80;
currentcal_8.dwFrequency1=852;
currentcal_8.dwFrequency2=1336;
currentcal_8.dwFrequency3=0;
currentcal_9.dwAppSpecific=1;
currentcal_9.dwDuration=80;
currentcal_9.dwFrequency1=852;
currentcal_9.dwFrequency2=1447;
currentcal_9.dwFrequency3=0;
//*
currentcal_10.dwAppSpecific=1;
currentcal_10.dwDuration=80;
currentcal_10.dwFrequency1=941;
currentcal_10.dwFrequency2=1209;
currentcal_10.dwFrequency3=0;
//#
currentcal_11.dwAppSpecific=1;
currentcal_11.dwDuration=80;
currentcal_11.dwFrequency1=941;
currentcal_11.dwFrequency2=1447;
currentcal_11.dwFrequency3=0;
// currentcall.MonitorTones_Add(1,80,697,1209,0);
// currentcall.MonitorTones_Add(2,80,697,1336,0);
// currentcall.MonitorTones_Add(3,80,697,1477,0);
// currentcall.MonitorTones_Add(4,80,770,1209,0);
// currentcall.MonitorTones_Add(5,80,770,1336,0);
// currentcall.MonitorTones_Add(6,80,770,1209,0);
// currentcall.MonitorTones_Add(7,80,852,1209,0);
// currentcall.MonitorTones_Add(8,80,852,1336,0);
// currentcall.MonitorTones_Add(9,80,852,1477,0);
/// currentcall.MonitorTones_Add(10,80,941,1209,0); //*
// currentcall.MonitorTones_Add(0,80,941,1336,0);
// currentcall.MonitorTones_Add(11,80,941,1477,0); //#
}
public void Addtext(ref string msg)
{
//fm = new Form1();
TextBox dtmf = new TextBox();
dtmf.Text=msg;
}
private void Form1_Load(object sender, System.EventArgs e)
{
// tapi = new AxTAPIEXLib.AxTAPIExCtl();
//tapi.initialize();
}
public void tapi_event(TAPI3Lib.TAPI_EVENT te,object eobj)//TAPI3Lib.ITToneDetectionEvent e,Object eventSender )
{
if(te==TAPI3Lib.TAPI_EVENT.TE_TONEEVENT)
{
TAPI3Lib.ITToneDetectionEvent e=(TAPI3Lib.ITToneDetectionEvent)eobj;
switch ( e.AppSpecific)
{
case 0:
string temp_string0 = "0";
Addtext( ref temp_string0);
break;
case 1:
string temp_string = "1";
Addtext(ref temp_string);
break;
case 2:
string temp_string2 = "2";
Addtext(ref temp_string2);
break;
case 3:
string temp_string3 = "3";
Addtext(ref temp_string3);
break;
case 4:
string temp_string4 = "4";
Addtext(ref temp_string4);
break;
case 5:
string temp_string5 = "5";
Addtext(ref temp_string5);
break;
case 6:
string temp_string6 = "6";
Addtext(ref temp_string6);
break;
case 7:
string temp_string7 = "7";
Addtext(ref temp_string7);
break;
case 8:
string temp_string8 = "8";
Addtext(ref temp_string8);
break;
case 9:
string temp_string9 = "9";
Addtext(ref temp_string9);
break;
}
}
else
{
string msg2="no tone";
Addtext(ref msg2);
}
}
}
thanks
|
|
|
|
|
First, read this[^]. Noone is going to read through all this code.
Second, is this a voice modem that's TAPI 3.0 capable?? If not, this is all for nothing.
|
|
|
|
|
thank u for your email which gives me very important infn.
I appriciate your help.
the modem is motorola 56000 voice data modem
i'm not sure if it's capable of tapi3.
thanks
|
|
|
|
|
Well, you better dig out the manual on the modem and find out. I'd hate to waste a bunch of time on something that the device doesn't support.
|
|
|
|
|
hi
thanks
i have checked the modem with some dialing
sofware called excel tele it it works(detects when ringing
and it could dial) and i think my problem is that i donn't
understand how to open the line device and phone device
and how i connect the modem with the handset and the computer
could u help me with this
thank you for your help
thanks
|
|
|
|
|
georgishelpmegodtoo wrote: excel tele it it works(detects when ringing
and it could dial)
Every modem ever made does this, and without using TAPI.
|
|
|
|
|
georgishelpmegodtoo wrote: Forum C#
Subject: Re: help me with tapi 3 call status and tone detection
Sender: georgishelpmegodtoo
Date: 17:17 4 Jun '07
hi
i'm developing a software using c# that detects the dialed digits and the status(sp when connected and desconnected) of a call that is made by a handset attached to the modem.
i have developed some code but it doesn't work.please someone help me it's urgent.
i connected the main line to one of the modems telephone jack and the handset with the other jack and the computer is connected using the serial port and then
here is the code for status of the call
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using TAPI3Lib;
namespace tapi3call_status
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
public TAPIClass tapiobject;
private ITAddress[] ia = new TAPI3Lib.ITAddress[10];
uint lines;
int line;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.ComboBox comboBox1;
private System.Windows.Forms.Label label3;
public System.Windows.Forms.TextBox textBox2;
public callstatus cs = new callstatus();
private System.Windows.Forms.ListBox listBox1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public class CLineDevice
{
public string d_Name;
public int d_ID;
public override string ToString()
{
return d_Name;
}
}
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
initializetapi3();
}
//
// TODO: Add any constructor code after InitializeComponent call
//
void initializetapi3()
{
tapiobject = new TAPIClass();
tapiobject.Initialize();
IEnumAddress ea = tapiobject.EnumerateAddresses();
ITAddress ln;
cs = new callstatus();
cs.addtolist = new callstatus.listshow(this.status);
tapiobject.ITTAPIEventNotification_Event_Event += new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(cs.Event);
uint arg3 = 0;
lines = 0;
for (int i = 0; i < 10; i++)
{
ea.Next(1, out ln, ref arg3);
ia[i] = ln;
if (ln != null)
{
comboBox1.Items.Add(ia[i].AddressName);
lines++;
}
else
break;
}
tapiobject.EventFilter = (int)(TAPI_EVENT.TE_CALLSTATE);
}
public void status(string str)
{
listBox1.Items.Add(str);
}
///
/// Clean up any resources being used.
///
protected override void Dispose(bool disposing)
{
tapiobject.Shutdown();
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.SuspendLayout();
//
// label1
//
this.label1.Location = new System.Drawing.Point(32, 80);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 16);
this.label1.TabIndex = 0;
this.label1.Text = "Call Status";
//
// button1
//
this.button1.Location = new System.Drawing.Point(184, 136);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(80, 24);
this.button1.TabIndex = 2;
this.button1.Text = "clear status";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 24);
this.label2.TabIndex = 3;
this.label2.Text = "line devices";
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(120, 16);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(224, 21);
this.comboBox1.TabIndex = 4;
this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(40, 208);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(80, 24);
this.label3.TabIndex = 5;
this.label3.Text = "Call Duration";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(120, 208);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(88, 20);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "0.0";
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(120, 72);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(192, 56);
this.listBox1.TabIndex = 7;
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(360, 254);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.label3);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
listBox1.Items.Clear();
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
line = comboBox1.SelectedIndex;
}
}
public class callstatus : TAPI3Lib.ITTAPIEventNotification
{
public StopWatch sw = new StopWatch();
public delegate void listshow(string str);
public listshow addtolist;
public void Event(TAPI3Lib.TAPI_EVENT te, object eobj)
{
Form1 fm = new Form1();
if (te == TAPI3Lib.TAPI_EVENT.TE_CALLSTATE)
{
TAPI3Lib.ITCallStateEvent a = (TAPI3Lib.ITCallStateEvent)eobj;
TAPI3Lib.ITCallInfo b = a.Call;
switch (b.CallState)
{
case TAPI3Lib.CALL_STATE.CS_INPROGRESS:
addtolist("dialing");
break;
case TAPI3Lib.CALL_STATE.CS_CONNECTED:
addtolist("Connected");
sw.Start();
fm.textBox2.Text = "0";
break;
case TAPI3Lib.CALL_STATE.CS_DISCONNECTED:
addtolist("Disconnected");
sw.Stop();
fm.textBox2.Text = sw.GetElapsedTimeMinutes().ToString();
break;
case TAPI3Lib.CALL_STATE.CS_OFFERING:
addtolist("A party wants to communicate with you!");
break;
case TAPI3Lib.CALL_STATE.CS_IDLE:
addtolist("Call is created!");
break;
}
}
}
public class StopWatch
{
private DateTime startTime;
private DateTime stopTime;
private bool running = false;
public void Start()
{
this.startTime = DateTime.Now;
this.running = true;
}
public void Stop()
{
this.stopTime = DateTime.Now;
this.running = false;
}
// elaspsed time in minutes
public double GetElapsedTimeMinutes()
{
TimeSpan interval;
if (running)
interval = DateTime.Now - startTime;
else
interval = stopTime - startTime;
return interval.TotalMinutes;
}
// elaspsed time in seconds
public double GetElapsedTimeSecs()
{
TimeSpan interval;
if (running)
interval = DateTime.Now - startTime;
else
interval = stopTime - startTime;
return interval.TotalSeconds;
}
}
}
}
and the code for detecting the dialed number
#define Win32
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using TAPI3Lib;
//using TERMMGRLib;
using System.Runtime.InteropServices;
//
using System.Threading;
using System.Data;
namespace tonedetection
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private System.Windows.Forms.TextBox dtmf;
public digitdetect dd = new digitdetect();
//public AxTAPIEXLib.AxTAPIExCtl tapi;
public TAPI3Lib.TAPIClass tapi;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
#region Windows Form Designer generated code
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
Initializetonemonit();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
public void Initializetonemonit()
{
try
{
tapi = new TAPIClass();
tapi.Initialize();
dd = new digitdetect();
dd.tapi_tonemonit();
tapi.ITTAPIEventNotification_Event_Event+= new TAPI3Lib.ITTAPIEventNotification_EventEventHandler(dd.tapi_event);
//tapi.EventFilter=(int)(TAPI_EVENT.TE_TONEEVENT);
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
}
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.dtmf = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// dtmf
//
this.dtmf.BackColor = System.Drawing.SystemColors.HighlightText;
this.dtmf.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dtmf.Location = new System.Drawing.Point(40, 104);
this.dtmf.Name = "dtmf";
this.dtmf.ReadOnly = true;
this.dtmf.Size = new System.Drawing.Size(216, 26);
this.dtmf.TabIndex = 1;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(392, 198);
this.Controls.Add(this.dtmf);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private void Form1_Load(object sender, EventArgs e)
{
}
/*
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
*/
///
/// The main entry point for the application.
///
}
}
public class digitdetect
{
//MonitorTones_Add 1, 80, 697, 1209, 0 ' "1"
//.MonitorTones_Add 2, 80, 697, 1336, 0 ' "2"
//.MonitorTones_Add 3, 80, 697, 1477, 0 ' "3"
//.MonitorTones_Add 4, 80, 770, 1209, 0 ' "4"
//.MonitorTones_Add 5, 80, 770, 1336, 0 ' "5"
//.MonitorTones_Add 6, 80, 770, 1477, 0 ' "6"
//.MonitorTones_Add 7, 80, 852, 1209, 0 ' "7"
//.MonitorTones_Add 8, 80, 852, 1336, 0 ' "8"
//.MonitorTones_Add 9, 80, 852, 1477, 0 ' "9"
//.MonitorTones_Add 10, 80, 941, 1209, 0 ' "*"
//.MonitorTones_Add 0, 80, 941, 1336, 0 ' "0"
//.MonitorTones_Add 12, 80, 941, 1477, 0 ' "#"
//************
//currCall.MonitorTones_Add(BUSY_ID, BusyTone.Duration, BusyTone.FirstFreq, BusyTone.SecondFreq, 0);
//*********
//Function MonitorTones_Add(
//AppSpecific As Long,
//Duration As Long,
//Frequency1 As Long, Frequency2 As Long, Frequency3 As Long ) As Boolean
//*************************
TAPI3Lib.TAPI_DETECTTONE currentcal_0;
TAPI3Lib.TAPI_DETECTTONE currentcal_1;
TAPI3Lib.TAPI_DETECTTONE currentcal_2;
TAPI3Lib.TAPI_DETECTTONE currentcal_3;
TAPI3Lib.TAPI_DETECTTONE currentcal_4;
TAPI3Lib.TAPI_DETECTTONE currentcal_5;
TAPI3Lib.TAPI_DETECTTONE currentcal_6;
TAPI3Lib.TAPI_DETECTTONE currentcal_7;
TAPI3Lib.TAPI_DETECTTONE currentcal_8;
TAPI3Lib.TAPI_DETECTTONE currentcal_9;
TAPI3Lib.TAPI_DETECTTONE currentcal_10;
TAPI3Lib.TAPI_DETECTTONE currentcal_11;
//public TAPIEXLib.ITAPICall currentcall;
public void tapi_tonemonit()
{
currentcal_0.dwAppSpecific=1;
currentcal_0.dwDuration=80;
currentcal_0.dwFrequency1=941;
currentcal_0.dwFrequency2=1336;
currentcal_0.dwFrequency3=0;
currentcal_1.dwAppSpecific=1;
currentcal_1.dwDuration=80;
currentcal_1.dwFrequency1=697;
currentcal_1.dwFrequency2=1209;
currentcal_1.dwFrequency3=0;
currentcal_2.dwAppSpecific=1;
currentcal_2.dwDuration=80;
currentcal_2.dwFrequency1=697;
currentcal_2.dwFrequency2=1336;
currentcal_2.dwFrequency3=0;
currentcal_3.dwAppSpecific=1;
currentcal_3.dwDuration=80;
currentcal_3.dwFrequency1=697;
currentcal_3.dwFrequency2=1447;
currentcal_3.dwFrequency3=0;
currentcal_4.dwAppSpecific=1;
currentcal_4.dwDuration=80;
currentcal_4.dwFrequency1=770;
currentcal_4.dwFrequency2=1209;
currentcal_4.dwFrequency3=0;
currentcal_5.dwAppSpecific=1;
currentcal_5.dwDuration=80;
currentcal_5.dwFrequency1=770;
currentcal_5.dwFrequency2=1336;
currentcal_5.dwFrequency3=0;
currentcal_6.dwAppSpecific=1;
currentcal_6.dwDuration=80;
currentcal_6.dwFrequency1=770;
currentcal_6.dwFrequency2=1447;
currentcal_6.dwFrequency3=0;
currentcal_7.dwAppSpecific=1;
currentcal_7.dwDuration=80;
currentcal_7.dwFrequency1=852;
currentcal_7.dwFrequency2=1209;
currentcal_7.dwFrequency3=0;
currentcal_8.dwAppSpecific=1;
currentcal_8.dwDuration=80;
currentcal_8.dwFrequency1=852;
currentcal_8.dwFrequency2=1336;
currentcal_8.dwFrequency3=0;
currentcal_9.dwAppSpecific=1;
currentcal_9.dwDuration=80;
currentcal_9.dwFrequency1=852;
currentcal_9.dwFrequency2=1447;
currentcal_9.dwFrequency3=0;
//*
currentcal_10.dwAppSpecific=1;
currentcal_10.dwDuration=80;
currentcal_10.dwFrequency1=941;
currentcal_10.dwFrequency2=1209;
currentcal_10.dwFrequency3=0;
//#
currentcal_11.dwAppSpecific=1;
currentcal_11.dwDuration=80;
currentcal_11.dwFrequency1=941;
currentcal_11.dwFrequency2=1447;
currentcal_11.dwFrequency3=0;
// currentcall.MonitorTones_Add(1,80,697,1209,0);
// currentcall.MonitorTones_Add(2,80,697,1336,0);
// currentcall.MonitorTones_Add(3,80,697,1477,0);
// currentcall.MonitorTones_Add(4,80,770,1209,0);
// currentcall.MonitorTones_Add(5,80,770,1336,0);
// currentcall.MonitorTones_Add(6,80,770,1209,0);
// currentcall.MonitorTones_Add(7,80,852,1209,0);
// currentcall.MonitorTones_Add(8,80,852,1336,0);
// currentcall.MonitorTones_Add(9,80,852,1477,0);
/// currentcall.MonitorTones_Add(10,80,941,1209,0); //*
// currentcall.MonitorTones_Add(0,80,941,1336,0);
// currentcall.MonitorTones_Add(11,80,941,1477,0); //#
}
public void Addtext(ref string msg)
{
//fm = new Form1();
TextBox dtmf = new TextBox();
dtmf.Text=msg;
}
private void Form1_Load(object sender, System.EventArgs e)
{
// tapi = new AxTAPIEXLib.AxTAPIExCtl();
//tapi.initialize();
}
public void tapi_event(TAPI3Lib.TAPI_EVENT te,object eobj)//TAPI3Lib.ITToneDetectionEvent e,Object eventSender )
{
if(te==TAPI3Lib.TAPI_EVENT.TE_TONEEVENT)
{
TAPI3Lib.ITToneDetectionEvent e=(TAPI3Lib.ITToneDetectionEvent)eobj;
switch ( e.AppSpecific)
{
case 0:
string temp_string0 = "0";
Addtext( ref temp_string0);
break;
case 1:
string temp_string = "1";
Addtext(ref temp_string);
break;
case 2:
string temp_string2 = "2";
Addtext(ref temp_string2);
break;
case 3:
string temp_string3 = "3";
Addtext(ref temp_string3);
break;
case 4:
string temp_string4 = "4";
Addtext(ref temp_string4);
break;
case 5:
string temp_string5 = "5";
Addtext(ref temp_string5);
break;
case 6:
string temp_string6 = "6";
Addtext(ref temp_string6);
break;
case 7:
string temp_string7 = "7";
Addtext(ref temp_string7);
break;
case 8:
string temp_string8 = "8";
Addtext(ref temp_string8);
break;
case 9:
string temp_string9 = "9";
Addtext(ref temp_string9);
break;
}
}
else
{
string msg2="no tone";
Addtext(ref msg2);
}
}
}
georgishelpmegodtoo wrote: thanks
Are you serious .. I think you're missing the joke icon!
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
As tapi3 is com based so u have to initiate it properly
then get all the devices
open the devices
and then listen for events
one important thing as someone else mentioned it it's very important that u should know that your modem supports the functionality that it will raise a event on DTMF.
|
|
|
|
|