|
Can somebody tell me how can i use the modem port to build a 'Phone Dailer' program.
I cann't understend how to use the modem port in c# to dial a call and recive a call.
Alex
|
|
|
|
|
Click "Search comments" directly above this message board and search for "TAPI". You can also search the Internet for "C# TAPI" for relevant articles (some of which should be on this site as well).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I know there must be a better way to do this. I have a project that references another project. The second project needs to access the first projects app.config file. I could do this just by calling the file by name and accessing it as an XML file but before I go and do all that is there a better way out there somewhere that I just haven't found???
-Richard
|
|
|
|
|
|
Hey Nick, thanks for the reply but at a quick glance it looked like your manager only handled the current projects config file? Even if I missed the way to access another config file it really ends up being more code than I want to add. If I just open the xml document it will only take like 5 lines of code. I was really just interested in seeing if I had missed some .Net method along the way that would be easier or faster
-Richard
|
|
|
|
|
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Xml.Xsl;
using System.Xml;
namespace PDM.excel
{
///
/// Summary description for WebForm3.
///
public class WebForm3 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
public SqlConnection conDB = new SqlConnection();
static public string[] LanguageStr =
{
"English","French","Spanish"};
static public string[] DropDownListStr =
{
"Language_DropDownList"};
protected System.Web.UI.WebControls.DropDownList Language_DropDownList;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;
static public string[][] AddStrArray =
{
LanguageStr};
private void Fill_DropDownList()
{
for (int i = 0; i < DropDownListStr.Length; i++)
{
string CtrlName= DropDownListStr[i];
DropDownList MyList = (DropDownList)Page.FindControl(CtrlName);
// Populate all the checkboxes
string[] ToPopulate = AddStrArray[i];
for (int j = 0; j < ToPopulate.Length; j++)
{
MyList.Items.Add(new ListItem(ToPopulate[j], j.ToString()));
}
}
}
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack)
{
Fill_DropDownList();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Language_DropDownList.SelectedIndexChanged += new System.EventHandler(this.Language_DropDownList_SelectedIndexChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
public DataSet DataToExcel = new DataSet();
public void BindGrid (int index)
{
conDB.ConnectionString = "data source=10.195.17.7;database=devnew;uid=bounaajak;pwd=ehsfirst;packet size=4096";
SqlDataAdapter da = new SqlDataAdapter("Select string_id, string from pdm_translations where language_id = 1 and string_id not in (select string_id from pdm_translations where language_id = " + index.ToString() + ") ", conDB);
da.Fill(DataToExcel, "DataToExcel");
Session["Tabla"] = Language_DropDownList.SelectedItem.Text;
DataToExcel.WriteXml(Server.MapPath(Session["Tabla"] + ".xml"));
DataGrid1.DataSource = DataToExcel;
DataGrid1.DataBind();
// Get row count
int nRowCount = DataToExcel.Tables["DataToExcel"].Rows.Count;
// Store Row count in Session variable
Session["RowCount"] = nRowCount;
}
private void Language_DropDownList_SelectedIndexChanged(object sender, System.EventArgs e)
{
int getSelectedIndex = Language_DropDownList.SelectedIndex+1;
BindGrid(getSelectedIndex);
}
public void DataGridToExcel(DataGrid Export,HttpResponse Response)
{
// Set the Response mime type for excel
Response.ContentType = "application/vnd.ms-excel";
// Create a String Writer
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
DataGrid1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
private void Button1_Click(object sender, System.EventArgs e)
{
DataGridToExcel (DataGrid1, Response);
}
}
}
|
|
|
|
|
This question belongs in the ASP.NET[^] forum.
|
|
|
|
|
Hi, iv got a program which has a networkstream for exchangin messages between a server and client......
The problem i had was that the client needs to keep checking the data stream for new messages sent from the server......as im no expert i originally implemented a endless while loop which checked for data in the incoming data buffer but obviously this caused my computer to crash with the number of checks it was doing..........
so i found out about the BeginRead() method which allowed me to create a seperate execution thread using a delegate and callback method......so then i could re call the beginRead() with in the thread so it continously read in formation from the stream............
Now, i dont think i understand how to implement them, as it seems to work one time round and then crashes, or reads data into the buffer that looks like \0\0\0\0\0\0\0\0\0\0\0 (what eva that means)..........i think i need some one to shed some light on these methods so i can get it to work??
cheers
sorry for the long message....
mike
|
|
|
|
|
mikeyhardingboyo wrote:
i originally implemented a endless while loop which checked for data in the incoming data buffer but obviously this caused my computer to crash with the number of checks it was doing
That's hardly obvious. I've done a lot of checks in programs and they've never crashed the app or the computer. So have many other developers. It's what applications do.
Understand that when you use BeginRead a read is started on another thread. The read itself is a blocking call. It does not return until there's data to actually read. If you keep calling BeginRead and there's never any data, then you've got many threads piling up, wasting memory, and doing nothing. Now all of a sudden when data arrives you've got a race condition.
Never use asynchronous Begin* methods without ever calling their corresponding End* functions. The mess you got into is the mess that will happen when you don't use asynchronous methods correctly.
If you want to know if data is available for a NetworkStream , check the NetworkStream.DataAvailable property. If you had checked the documentation - especially important if you're new to .NET development - you should've noticed this obviously named method.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I do use the DataAvailable property. My point is that when i initially call BeginRead() from my main thread, there is always data to read....thus is returns and allows the main thread to continue....
Thus in the seperate thread that the initial BeginRead call created I want it to block in that thread if there is no data to read, until data becomes available.....
Thus I have to have a form of iteration where the BeginRead() is called in the seperate thread so it can continue to check for data as long as the program is running.
As the seperate thread is executed i do call the EndRead() on each result of a BeginRead() call.
The method that the seperate thread executes looks like this...so are you telling me this is not possible?
public void myReadCallBack(IAsyncResult result)
{
NetworkStream str = (NetworkStream) result.AsyncState;
byte[] myReadBuffer = new byte[2048];
int numberOfBytesRead = 0;
numberOfBytesRead = str.EndRead(result);
myCompleteMessage = String.Concat(myCompleteMessage, Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
TokenizeCommands(myCompleteMessage);
myCompleteMessage = "";
stream.BeginRead(myReadBuffer, 0, myReadBuffer.Length, new AsyncCallback(myReadCallBack),stream);
}
mike
|
|
|
|
|
I'm not sure I follow you completely. All you need to do is use BeginRead once while your main thread of execution continues (to update an animated "wait" graphics or something). In your AsyncCallback you call EndRead as you're doing and you've call the data.
Take a look in the .NET Framework SDK documentation at the NetworkStream.BeginRead and EndRead methods. The two together form a complete solution (i.e., a callback is created in the docs for BeginRead that is defined in the example for EndRead ). What you have is similar, but the examples - and the documentation itself - may help you discover what the problem is.
Otherwise, please post your complete solution (minus any code that actually acts on the data or updates a UI, etc., for brevity's sake).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
O, you have helped me understand these methods better. But to clear things up in what im trying to achieve..........The bottom line is I want to be able to read data as it is sent down the stream over time.....Thus my program needs to be able to constantly monitor the stream in-order to react as it were when data(messages) are there to be read off.
So in my meain theard after the TCP connection has been set up I call a method which contains the following:
if(stream.CanRead)
{
byte[] myReadBuffer = new byte[2048];
stream.BeginRead(myReadBuffer, 0, myReadBuffer.Length, new AsyncCallback(myReadCallBack),stream);
}
After this is called the callback method is called (were the seperate thread executes)
The code in there looks like this:
public void myReadCallBack(IAsyncResult result)
{
NetworkStream str = (NetworkStream) result.AsyncState;
byte[] myReadBuffer = new byte[2048];
int numberOfBytesRead = 0;
numberOfBytesRead = str.EndRead(result);
myCompleteMessage = String.Concat(myCompleteMessage, Encoding.ASCII.GetString(myReadBuffer, 0, numberOfBytesRead));
while(str.DataAvailable)
{
str.BeginRead(myReadBuffer, 0, myReadBuffer.Length, new AsyncCallback(myReadCallBack),stream);
}
if(stream.DataAvailable == false)
{
TokenizeCommands(myCompleteMessage);
myCompleteMessage = "";
str.BeginRead(myReadBuffer, 0, myReadBuffer.Length, new AsyncCallback(myReadCallBack),stream);
}
}
}
Thats the code. So im trying to achieve structure that will monitor data when it becomes available on the stream but in an iterative way so the main thread can continue to do other things but react when messages become available on the stream.
thanks for ya help, its difficult for me to explain as im a student to this, but im getting there
cheers
mIKE
|
|
|
|
|
just one more thing, when I insert buttons in my form and when I set KeyPreview to true, the left/right/up/down/space keys move the focus from controls to controls. How can I take the control of the left/right/up/down/space keys?
thanks.
There is no spoon.
|
|
|
|
|
In your OnKeyDown override in your form set KeyEventArgs.Handled to true for those keys you want to process yourself.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
Even if I put the KeyEventArgs.Handled to true , the arrow and space bar keys are not processed. The OnKeyDown handler simply do the following:
private void OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)<br />
{<br />
Debug.WriteLine("frmMain.OnKeyDown: "+e.KeyCode.ToString());<br />
e.Handled=true;<br />
}<br />
in the OnLoad event of the main form, I just do:
private void OnLoad(object sender, System.EventArgs e)<br />
{<br />
this.MinimumSize=this.Size;<br />
this.KeyPreview=true;<br />
}
Maybe I have done something wrong somewhere???
There is no spoon.
|
|
|
|
|
You dno't need to do that in the Load event handler - just set it in the constructor. The same is true for MinimizeSize . Windows Forms will remember settings if they are not applicable yet, and will apply those when the are applicable (like after the handle is created inside OnHandleCreated ).
If those don't work for you, override (and be sure to call the base implementation) ProcessDialogKey which does handle the arrows and a few others keys in addition to the other keys.
It's all documented in the .NET Framework SDK if you look at the members for Control (from which Form indirectly derives).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
yes, overriding ProcessDialogKey works fine! all keys are processed.
Is the ProcessDialogKey the equivalent of the MFC'sPreTranslateMessage (with trapping WM_KEYDOWN )?
There is no spoon.
|
|
|
|
|
Hello gurus,
There is a strange behaviour with Windows Forms... is it me or is it normal?
Here is what's happening:
When I create an empty form that handles the KeyDown event the event is triggered.
But, when I insert a control like my own control or a buttons etc., the KeyDown event is not triggered: I never enter in the KeyDown event...
Why does this happen?? I have done something wrong?
Thanks
Best regards.
There is no spoon.
|
|
|
|
|
When a control has the focus its message handler (reflected WndProc in managed code) is sent the message. You need to set Form.KeyPreview to true in order for the form to process keyboard messages for child controls. See the .NET Framework SDK documentation for more details.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
ok, it was because of the KeyPreview property. I'm going to check the MSDN...
thanks
There is no spoon.
|
|
|
|
|
I have a quick question about the dateTimePicker included with Visual Studio. I only need to use the month and the date so I was wondering if I could disable or remove the calendar part of the dateTimePicker when the user clicks the drop down arrow?
Thanks
|
|
|
|
|
What exactly are you trying to do? If you're just trying to display a date and not let them pick a date, then just format a DateTime to the stirng format you want:
label1.Text = DateTime.Now.ToString("m"); For more information about the format codes allowed for DateTime.ToString read about it in the .NET Framework SDK, which is installed by default with VS.NET and is available online at http://msdn.microsoft.com/library[^].
If you disable the calendar, how is the user to pick a date? Yes, they can use the arrow buttons but many people don't know about that and it is cumbersome to use.
Do you only want to disable the year selection of the calendar? While not impossible it's not supported by the calendar control (which is actually the native Month Calendar control from Windows Common Controls) and you would have to go to quite a bit of work to clip it or hide that portion of owner-drawn content and to not allow notification messages to be sent when actions occur over those coordinates (like a mouse click).
If you want to allow the user to only see the month and day, then use a custom format by setting the DateTimePicker.CustomFormat property and in the code that uses the DateTime ignore the year.
Other than that you'll need to develop your own control.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I wanted to only allow the user to pick a month and a year. I do not need to use a date.
|
|
|
|
|
Anonymous wrote:
I only need to use the month and the date...
Your first statement was rather ambiguous.
Still, though, there is no support from the Common Control (and, hence, none in the Windows Forms control that encapsulates it) to hide the day select either.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have just started this. and i m trying to make a chat application that runs over LAN.
there might be many other ways and they might be better then using Udp port but i want to understand this thing. i have read some articles before posting but i m now having problem on receiveing messages.
public void waitData()<br />
{<br />
while(true)<br />
{<br />
IPEndPoint from = new IPEndPoint(IPAddress.Any,170);<br />
<br />
<br />
string result = "";<br />
Byte[] drec = receive.Receive(ref from);<br />
result = Encoding.ASCII.GetString(drec);<br />
textBox1.Text = result.ToString();<br />
<br />
}<br />
}
this code is to recieve messages and i made a thread so it keep waiting for any message to recieve. and i m broadcasting message to network.
i m new to this so plz help me
i think its enough to explain what i want to do but if still you think i had to tell more. tell me.
|
|
|
|