|
I would like to show a VC8 C# Form inside a VC6 C++ MDI application. Is this possible? If so can anyone refer me a web-site as to how this is done? I am thinking about creating a C# DLL that can be loaded into the VC6 C++ MDI application that can return Child window.
Chris
|
|
|
|
|
I want to write a program in c# with this feature:
program call to a phone number and when phone have been answered,play a sound message(Wave file)for it.
please guide me how can i do it?
|
|
|
|
|
Hello
This will involve 2 parts:
1- Calling the phone : You will be using something calld TAPI 3.0 to do it.
2- Playing the audio stream to the modem's voice line: You'd use DirectX to do it.
Search CodeProject's articles section for details.
Regards
|
|
|
|
|
Excellent and Great. I really did not know that dialing phone call was so easy with C#. I already found a nice article in CodeProject for using TAPI.
http://www.codeproject.com/cs/internet/devangpro.asp[^]
Before I was harvesting for articles in google about dialing phone using C# and I did not know the right keyword and I ended up with some commercial libraries which was sooo expensive like starting from 1000US$.
By the way,
Nader Elshehabi wrote: 2- Playing the audio stream to the modem's voice line: You'd use DirectX to do it.
-- Why do I need so complicated solution to play audio stream to the modem's voice line ( I mean, using DirectX). Should not there be some easy windows method to play mp3 files directly to Modem's Voice line ?
Do you know any article which describe How to play mp3 files or direct Microphone line to Modem's voice line ?
Regards and thansk always
As you are the best friend for all C# coders in this forum.
Emran
|
|
|
|
|
Hello
Well, now we know TAPI could save someone 1000$. This could work as a commercial .
Playing audio directly to any audio line using DirectX sound reasonable, doesn't it? It's all I can think of.
About the article try this[^]. I don't think it considers modem voice line, but it discusses audio lines in general. If it doesn't work, hint me and I'll investigate more.
Extra Regards
|
|
|
|
|
Hi.thanks for your guidances.
I downloaded TAPI 3.0 example but I receive this error message during execution of program:'compobj.dll is too old for the ole2.dll initialized (Exception from HRESULT: 0x8004000E (OLE_E_WRONGCOMPOBJ))'.
please introduce a higher version of this DLL file.
best regards.
|
|
|
|
|
Posting the code that throws that exception would do some help. I think it is not TAPI related at all!!
Regards
|
|
|
|
|
Hi.
I use this code to call to a number:
TAPI3Lib.ITAddress ln=null;
ln=ia[line];
if(textBox1.Text.Length!=0)
{
MessageBox.Show(""+textBox1.Text,"Calling to");
try
{
if(!h323)
{
bcc = ln.CreateCall(textBox1.Text,TapiConstants.LINEADDRESSTYPE_PHONENUMBER|TapiConstants.LINEADDRESSTYPE_IPADDRESS,TapiConstants.TAPIMEDIATYPE_DATAMODEM|TapiConstants.TAPIMEDIATYPE_AUDIO);
bcc.SetQOS(TapiConstants.TAPIMEDIATYPE_DATAMODEM|TapiConstants.TAPIMEDIATYPE_AUDIO,QOS_SERVICE_LEVEL.QSL_BEST_EFFORT);
bcc.Connect(false);
}
else
{
bcc = ln.CreateCall(textBox1.Text,TapiConstants.LINEADDRESSTYPE_IPADDRESS,TapiConstants.TAPIMEDIATYPE_AUDIO);
bcc.Connect(false);//I receive Error in this line!!!
}
}
catch(Exception exp)
{
MessageBox.Show("Failed to create call!","TAPI3");
}
}
else
{
MessageBox.Show("Please enter number to dial.. ");
}
best regards.
|
|
|
|
|
I think this should be:
bcc = ln.CreateCall(textBox1.Text,TapiConstants.LINEADDRESSTYPE_PHONENUMBER,TapiConstants.TAPIMEDIATYPE_AUDIO);
bcc.Connect(false);
if you want to make a voice call. Why set it to DATAMODEM?!!
Regards
|
|
|
|
|
thank you so so much.your guidance solve my problem.now please help me in these cases:
1-how can I understand that phone have been answerd by program code?
2-how can I play a wave file for listener?
I have a special thanks.
best regards
|
|
|
|
|
Um.. Sorry! I haven't gone that far in TAPI. There ought to be an event fired when the phone is answered, but I don't remember it. Mose of my work with TAPI was about Data calls. Search for the event notification registration. You should register the event that you want to handle. About the voice file playing, modem's line is just another audio line. You got two options:
1- There is a stream object that is associated with the call -maybe even multiple streams-. Check it out if you can stream your audio through it.
2- Use DirectX to play the audio to the modem's audio line as you would to the speakers.
I hope I could have helped you better, but as I told you, my experience is with data calls. Good luck!
Regards
|
|
|
|
|
Hi.
I wrote a program with C# and use TAPI.My program dial a number and play a wave file for listener.
I use a event handler for managing call state:
m_CTapi.CallStateEvent += new CTapi.CallStateEventHandler(MyCallStateEventHandler);
public void MyCallStateEventHandler(Object sender, CTapi.CallStateEventArgs e)
{
switch ( e.CallState )
{
case CTapi.LineCallState.LINECALLSTATE_CONNECTED:
lsb_CallStatus.Items.Add("Call Connected...");
break;
case CTapi.LineCallState.LINECALLSTATE_DISCONNECTED:
lsb_CallStatus.Items.Add("Call Disconnected...");
break;
case CTapi.LineCallState.LINECALLSTATE_ONHOLD:
lsb_CallStatus.Items.Add("Call Hold...");
break;
case CTapi.LineCallState.LINECALLSTATE_IDLE:
lsb_CallStatus.Items.Add("Call Idle...");
break;
case CTapi.LineCallState.LINECALLSTATE_PROCEEDING:
lsb_CallStatus.Items.Add("Call in Progress...");
break;
case CTapi.LineCallState.LINECALLSTATE_OFFERING:
lsb_CallStatus.Items.Add("Call Offering...");
break;
case CTapi.LineCallState.LINECALLSTATE_ACCEPTED:
lsb_CallStatus.Items.Add("Call Accepted...");
break;
case CTapi.LineCallState.LINECALLSTATE_DIALING:
lsb_CallStatus.Items.Add("Call Dialing...");
break;
case CTapi.LineCallState.LINECALLSTATE_RINGBACK:
lsb_CallStatus.Items.Add("Call Ringback...");
break;
case CTapi.LineCallState.LINECALLSTATE_BUSY:
lsb_CallStatus.Items.Add("Call Busy...");
break;
case CTapi.LineCallState.LINECALLSTATE_SPECIALINFO:
lsb_CallStatus.Items.Add("Call Special Info...");
break;
case CTapi.LineCallState.LINECALLSTATE_DIALTONE:
lsb_CallStatus.Items.Add("Dial Tone...");
break;
}
}
Now my problem:when program dial a number and receive the first telephone ring,MyCallStateEventHandler receive 'Connected' event but I need to understand when a person pick up the phone(and he is listening)????how can I do this?
It's wonderful that these call states never happened:
LINECALLSTATE_ONHOLD,LINECALLSTATE_ACCEPTED,LINECALLSTATE_OFFERING,LINECALLSTATE_RINGBACK,LINECALLSTATE_BUSY,LINECALLSTATE_SPECIALINFO,LINECALLSTATE_DIALTONE
please help me to solve my problem.
best regards
|
|
|
|
|
HojatAlizadehfard wrote: I wrote a program with C# and use TAPI.My program dial a number and play a wave file for listener.
Good! I'm glad you made it!! So, which approach did you choose to send the audio? Please don't forget to tell me, I'm interested in this point.
HojatAlizadehfard wrote: m_CTapi.CallStateEvent += new CTapi.CallStateEventHandler(MyCallStateEventHandler);
I don't know why did choose to handle that event yourself, but here is my approach:
TAPIClass tapi;
ITAddress address;
ITBasicCallControl TheCall;
((ITAddress2)address).set_EventFilter(TAPI_EVENT.TE_CALLNOTIFICATION, 0, true);
((ITAddress2)address).set_EventFilter(TAPI_EVENT.TE_CALLMEDIA, 0, true);
tapi.ITTAPIEventNotification_Event_Event += new ITTAPIEventNotification_EventEventHandler(tapi_ITTAPIEventNotification_Event_Event);
int test = tapi.RegisterCallNotifications(address, true, true, TapiConstants.TAPIMEDIATYPE_DATAMODEM, 1);
void tapi_ITTAPIEventNotification_Event_Event(TAPI_EVENT TapiEvent, object pEvent)
{
switch (TapiEvent)
{
case TAPI_EVENT.TE_CALLNOTIFICATION:
{
TheCall = (ITBasicCallControl)(((ITCallNotificationEvent)pEvent).Call);
DialogResult res = MessageBox.Show("Answer?", "Incoming", MessageBoxButtons.YesNo);
if (res == DialogResult.Yes)
TheCall.Answer();
else
TheCall.Disconnect(DISCONNECT_CODE.DC_REJECTED);
break;
}
case TAPI_EVENT.TE_CALLMEDIA:
{
if (((ITCallMediaEvent)pEvent).Cause == CALL_MEDIA_EVENT_CAUSE.CMC_LOCAL_REQUEST
|| ((ITCallMediaEvent)pEvent).Cause == CALL_MEDIA_EVENT_CAUSE.CMC_REMOTE_REQUEST)
{
MessageBox.Show("data");
}
break;
}
}
}
Sorry, my application is about data calls so, it might look a bit different. My point is I use TAPI_EVENT.TE_CALLNOTIFICATION call notification event instead of Call state.
Tell me if it worked, if not, I'll try to look up more.
Regards
|
|
|
|
|
Greetings:
What is the accepted method used for forms and/or background processes to communication with one another asynchronously under C#.
For example, I have written my share of Windows apps under C++ and MFC that involve handling serial ports, USB ports or other such external sources. My usual approach is to monitor the port with a worker thread for incoming data. I might have a display window in the application that simply waits for incoming messages which can come in at any time without prompting. I usually create some sort of messaging structure and pass messages from the monitoring thread to the window using PostMessage. For those not familiar, PostMessage simply puts the message into the message queue and does NOT wait for a response or any indication that the message was received. This is in contrast to SendMessage, which waits for the message to be handled and is therefore not much different from calling the handler directly.
So I am looking for a means to do something similar under C# and .NET.
How is this accomplished in general?
Thank you in advance to anyone who responds.
Mark
|
|
|
|
|
|
Hello
Well, you can do almost the same with C# using SerialPort class, but for lpt, USB, and other ports or devices you have to do it this way:
1- Call API function CreateFile() with the port/device name.
2- Get the handle returned by that call and pass it to FileStream constructor
3- Use that FileStream object to read/write from/to the port/device.
I hope that was close enough.
Regards
|
|
|
|
|
Hi Nader, thanks for your response.
I guess the example I gave was a bit too specific. In general, I am looking for the general accepted way for threads and forms to send messages to each other asynchronously. For a more general example, Lets say there is a parent form that launches another form using "Show" so that the new form behaves like a modeless dialog. Now, the new form has controls of various stripes on it and the parent form need not know about everything that is going on on this form but needs to be notified of certain key events. And lets say that simply calling some member function of the parent form from the child form isn't quite going to work. In Win32 programming and MFC, we would send asynchronous messaged from one window to another using the messaging system built into windows. As long as your thread or window has a message pump, then it should get the message.
Is there anything like this for C#?
Regards,
Mark
|
|
|
|
|
Well, I think you are getting a little meticulous about details here . It's nice though not much seen these days.
Exchanging messages between forms has many forms , depending on your needs and design. There may not be a best practice that is considered an industrial standard or a windows logo criteria, rather it's just a mere advice that could be criticized by another programmer.
Jethro63 wrote: Now, the new form has controls of various stripes on it and the parent form need not know about everything that is going on on this form but needs to be notified of certain key events
Once I read that sentence I had the word interface jumping across my eyes. It would be a nice way to make a standard of communicaion between your parent form and different MDIChild types -ie. through a common interface-.
Jethro63 wrote: And lets say that simply calling some member function of the parent form from the child form isn't quite going to work
Well, actually it can be done using Parent.Invoke() method for events that you want your child form to wait for the parent to excute its code. If you want to fire an event in the parent form and not to wait until it's done, call Parent.BeginInvoke() instead. Both calls of course are from your child forms.
Jethro63 wrote: In Win32 programming and MFC, we would send asynchronous messaged from one window to another using the messaging system built into windows. As long as your thread or window has a message pump, then it should get the message.
Well, you still can use the same thing in C# if you like it. Actually the messaging system is still applicable -even in Windows Vista I think-, so simply:
1- In the child form call Windows API PostMessage() or SendMessage() functions -whichever suits you-, using P/Invoke and give it the handle of the parent form.
2- In the parent form implement IMessageFilter interface and use its PreFilterMessage() to catch your custom message or use any way that suits you -usually there are predefined handlers- to catch WM_ standard messages if you wish to send them.
Jethro63 wrote: Is there anything like this for C#?
In addition to the above there are more improvised ways like exchanging data between forms -considered as threads- using System.Runtime.Remoting.IPCChannel class, or even sockets -one form is listener and the other is client-, but I don't think they would be an interesting choice to you.
I hope that was useful.
Regards
|
|
|
|
|
Hi Nader:
Thanks for the advice. I am looking into Parent.BeginInvoke(), which I recognized in passing and will now take a closer look at.
Cheers,
Mark
|
|
|
|
|
Hello,
I have a problem with using the SmtpClient class in .net, It works fine when sending mails within the mail server (same domain). But as soon as i send to an external mail-address, i get the error: "Server Prohibited. We do not relay". Im not sure what to do here.
If you have any ide, please give me a tip.
Regards
Hmitosh
|
|
|
|
|
That's not a problem with the class, that is how your SMTP server is configured, as the message indicates.
led mike
|
|
|
|
|
Usually Most ISPs block using SMTP servers to send email other than their own SMTP Server. You should ask your ISP to get their SMTP Server, and if authentication required ...etc... information... After that, try with your ISP's SMTP server to send email. Hope that will work.
|
|
|
|
|
i want to assign multiple values to one key value eg.
a: 1,2,3,4
b:5,6,7,8
nd so on
what data structure shall i use as hash table is of no use in such situation
Bia
|
|
|
|
|
You can store your array of values in an ArrayList, and then store that in the Hashtable.
Ex:
Hashtable hashtable = new Hashtable ();
hashtable["a"] = new ArrayList (new Int32[] {1, 2, 3, 4});
hashtable["b"] = new ArrayList (new Int32[] {5, 6, 7, 8});
...
|
|
|
|
|
yeh we did that but how can we get the key by knowin the values is there any way??
cuz it alwaz givs us null
|
|
|
|