|
Sir,
I am Prakash Halder, facing some problem in message box in C#, as follows,
I am writing the code for dispalaying message in MSVS2005 as:
using System.Windows.Forms;
MessageBox.show("Hello World");
error: namespace Windows is not exist in namespace System.
how can I solve this problem.
Thanking you
Prakash Halder
|
|
|
|
|
add in the reference system.windows.form.
then write this code above: using system.windows.form
it will run.
Happy Coding
|
|
|
|
|
Probably you are missing the reference...
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
hi..
i don't know how to handle mouse events.. i know the logic that when mouse left button is down it will chechk the cordinates if the square is drawn on those cordinates it will turn into diamond..i have drawn square i have drawn diamond but dnt know the actual thing how to do it..
[code]
private void Shapes_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawRectangle(Pens.Blue, 180, 80, 80, 80);
e.Graphics.DrawPolygon(Pens.Orange, new Point[] { new Point(300,
100), new Point(400, 300), new Point(300,
500), new Point(200, 300) });
}
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:24am.
|
|
|
|
|
i did it like this:
private void Shapes_MouseDown(object sender, MouseEventArgs e)
{
if (e.X > 179 && e.X < 259 && e.Y > 79 && e.Y < 159)
{
// Draw shapes here...
e.Graphics.DrawPolygon(Pens.Orange, new Point[] { new int(300,
100), new Point(400, 300), new int(300,
500), new Point(200, 300) });
}
}
as i draw the square in paint event..but now it gives this error..
'System.Windows.Forms.MouseEventArgs' does not contain a definition for 'Graphics' and no extension method 'Graphics' accepting a first argument of type 'System.Windows.Forms.MouseEventArgs' could be found (are you missing a using directive or an assembly reference..
|
|
|
|
|
I would advice you to carefully read the compiler output and take some time to reflect upon what it means.
Are you missing a using directive or an assembly reference?
It may be that the solution was right in front of you all along.
|
|
|
|
|
i have fixed that problem...now i want that when this polygon is drawn the square becomes invisible which was already on the form..
private void Shapes_Paint(object sender, PaintEventArgs e)
{
if (Square.Checked == true)
{
e.Graphics.DrawRectangle(Pens.Red, 180, 80, 80, 80);
}
if (Triangle.Checked == true)
{
e.Graphics.DrawPolygon(Pens.Red, new Point[] { new
point(300, 150), new Point(400,
250), new Point(200, 250)});
}
}
private void Shapes_MouseDown(object sender, MouseEventArgs e)
{
if (Square.Checked == true)
{
if (e.X > 179 && e.X < 259 && e.Y > 79 && e.Y < 159)
{
g.DrawPolygon(Pens.Orange, new Point[] { new Point(300,
100), new Point(400, 300), new Point(300,
500), new Point(200, 300) });
}
}
}
|
|
|
|
|
hello....
i am working on a project(c#).. i need a module to read bar code (EAN-13).
plz help me ... it,s urgent...
|
|
|
|
|
AFAIK you dont need to do anything on your application. Just place the cursor on correct textbox and read the barcode, the barcode will be copied to your textbox.
In addition to this it also places one acceptkey, so you can do the searching just after the barcode gets into the textbox.
|
|
|
|
|
I need to do the following on many remote pcs:
1. Check if a file exists and delete it.
2. Run a cmd command on remote pc which will create the file.
3. Read the file.
I am using C# and to run the command line on remote pcs I am starting a process and using psexec.
It works but problem is that it is very slow.
Any alternatives? I am really desperate and need to get this project going.
CodingYoshi
Artificial Intelligence is no match for Human Stupidity.
|
|
|
|
|
Reposting the same question is not going to get a quicker answer
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Please can anyone help me with the codes on voice streaming of the following scenario...
I want to develop a code which can run on my PDAs making both of them to be able 2 communicate with each other over a network (the PDAs are wi-fi enabled)
Mode of communication is : 1. Voice calls
2. Text messaging
I intend to have a server (my laptop) which handles the whole of the switching process, and also is able to pass voice n data btw itself and the PDAs.
Scenario
Have two personal digital assistants ( PDAs) and my laptop which connect to each other over a network.
I need to develop a code which will help stream voice and data over the network, making the PDAs able to make voice calls to each other and also to my laptop which also acts as the server or switching system here.
The laptop helps to switch calls btw both parties and also help to initiate an end to call btw both parties.
The laptop also runs both the client aand server software.
The switching should be fast and effective...Compression of voice over the network is allowed.
Thanks
|
|
|
|
|
So what is the problem, what have you tried, what is stopping you from developing the code.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I've got 1 accepted connection from TcpClient in async TcpListener.
I read all data from the client and then close its connection. But it might not be closed as described in the previous post.
After I invoke Stop() in TcpListener it recieves async client connect message. Then in that handler the System.ObjectDisposedException in System.Net.Sockets.Socket EndAccept(System.IAsyncResult) happens with message access to destroyed object is prohibited. object name "System.Net.Sockets.Socket"
What is the reason for that?
private void TcpListenerClientConnectAsyncCallback(IAsyncResult ar)
{
TcpListener tcpListener = (TcpListener)ar.AsyncState;
TcpClient tcpClient = this.tcpListener.EndAcceptTcpClient(ar);
NetworkStream ns = tcpClient.GetStream();
ns.BeginRead(buffer, 0, 1024, new AsyncCallback(TcpListenerDataReadAsyncCallback), tcpClient);
tcpListener.BeginAcceptTcpClient(new AsyncCallback(TcpListenerClientConnectAsyncCallback), tcpListener);
}
Also is there a way to notify the TcpListener that the TcpClient disconnected from its side? as in C++ winsock using windows messages FD_ACCEPT, FD_READ, ... ?
Чесноков
|
|
|
|
|
Before closing listener, you need to send a message to all connected clients indicating the exit. Clients should accept this message and disconnect itself. Once all the clients are disconnected, it is safe to close the listener.
Best wishes,
Navaneeth
|
|
|
|
|
That is great of adding additional messages with TcpClient/TcpListener classes. It sounds wierd to add specific messages to be processed by them to indicate they are due to close
In any case, I close the connection from client to server and from server to client by closing NetworkStream first and then the TcpClient.
tcpClient.GetStream().Close();
tcpClient.Close();
It does not affect them in either way, still producing those ClientAccept message to server
Are there better ways to work with Socket class instead of that Tcp abstraction?
Чесноков
|
|
|
|
|
It looks like you are new to network programming. I'd suggest to stay away from asynchronous methods for now. Spawn new threads or use ThreadPool to do the work. Once you feel comfortable with that design, try for asynchronous method. Manually creating threads and using it for handling connections and messages works well. You need asynchronous methods only when you need high scalability.
That said, there is no method to stop the asynchronous call especially when the call involves unmanaged code execution. A call to EndAccept will not help as it waits until the operation completes.
Chesnokov Yuriy wrote: Are there better ways to work with Socket class instead of that Tcp abstraction?
It depends on what you are doing. If you are doing for learning, TcpListener and TcpClient should be enough. For any serious network programming work with Socket class directly. This[^] MSDN article may help you.
Best wishes,
Navaneeth
|
|
|
|
|
No. I'm new to C# sockets.
I was coding async sockets in C++ before with winsock. It has windows handle to process all connection/disconnection etc... messages
Internet Traffic Firewall and Sniffer[^]
MFC Telnet Application[^]
C# sockets in async mode are quite different
Чесноков
modified on Sunday, November 1, 2009 6:51 AM
|
|
|
|
|
BTW if no clients have been connected to the TcpListener, that ClientConnect message still happen???
Чесноков
|
|
|
|
|
Do you mean TcpListenerClientConnectAsyncCallback method will get called if no clients connected? It will not get called when there are no connections.
Best wishes,
Navaneeth
|
|
|
|
|
Yes. After I call Stop() method on TcpListener.
Чесноков
|
|
|
|
|
How to notify TcpClient that it is disconnected?
1. I start async TcpListener
2. Once the client is connected it reads all data it sent also in async mode
3. Then simply close NetworkStream and close the client connection
private void TcpListenerDataReadAsyncCallback(IAsyncResult ar)
{
TcpClient tc = (TcpClient)ar.AsyncState;
NetworkStream ns = tc.GetStream();
ns.Close();
tc.Close();
}
In the client console, I wait in the loop with small sleeps for a long long while to wait if the server will send somthing, testing tcpClient.Connected property.
But it never becomes false???
Чесноков
|
|
|
|
|
Polling is one way to identify the listener status. You have to send a message to server and check the delivery status. If message got delivered successfully, server is connected.
Best wishes,
Navaneeth
|
|
|
|
|
Sending the message will induce the listener to recieve it and process.
In the listener I handle specific messages. It will need to process then connection test message in addition?
Do I need to insert additional sending of some data in that loop? with NetworkStream
for (int i = 0; i < 10 * 5; i++)
{
if (networkStream.DataAvailable == true)
{
}
Thread.Sleep(100);
if (tcpClient.Connected == false)
{
break;
}
}
Чесноков
|
|
|
|