|
I got it working, needed to change a setting - set the trigger mode to internal. Using fixed worked great.
Thank you!
|
|
|
|
|
Well done.
BTW: I did not get an email notification this time, because you replied to one of your own messages...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I forgot the example C code:
int nImageSize = nWidth * nHeight;
WORD* pDataBuff = new WORD[ nImageSize ];
if( pDataBuff != NULL )
{
memset( pDataBuff, '\0', nImageSize );
// Acquire the image data
DcamCapture( pDataBuff, nImageSize * 2 );
}
|
|
|
|
|
I don't know why all the LinkButton in my C#.net website cann't work,
It means that if i clicked the button just like i have nothing to do with it.
Can someone help me?waiting online
the browser has not any problem.
modified on Saturday, March 14, 2009 12:09 PM
|
|
|
|
|
what browser you're using...? BTW you should ask this in asp forum
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi!
Have you tried setting AutoPOstBAck property
Thanks!
Develop2Program & Program2Develop
|
|
|
|
|
I want to execute a CLASS in C#.NET 2.0 Console Application
I don't want to use Main() in the Program
How to Achive this I try the following code but it won't works
using System;
class StaticTest
{
static StaticTest()
{
Console.WriteLine("Hello!");
}
}
I know that there MUST be SOME WAY by which we can CREATE such a CLASS in C#.NET 2.0
BUT I don't Understand that HOW????????????????
THANKS in ADVANCE .....
With due respect to all those who replied me.
SIR I am not asking about creating Library or I don't want to make the object of this class at any other class Inside Main(),Simply I don't wanna use Main().
Actually this is not just a question its a Challange for me I am Searching over it and I hope that I will definately Found Some Satisfactory answer
If you could Help me than Please Help Me.
Bcoz I simply belive that-
"A TRUE Programmer can Code whatever he THINKS there is Nothing impossible for a TRUE Programmer"
modified on Saturday, March 14, 2009 2:58 PM
|
|
|
|
|
You MUST have at least one Main method in your application to act as an entry point.
If you have more than one Main method in your application, you can specify the startup object from the project's properties. But it's not the case here.
[Edit]Xmen is correct. I was talking about executables. I forgot about libraries.[/Edit]
The method you have here is a static constructor, a method that will be called only the first time you use that class in any way.
You can create objects from that class normally just like any other classes.
static void Main(string[] args)
{
StaticTest s1 = new StaticTest();
StaticTest s2 = new StaticTest();
StaticTest s3 = new StaticTest();
}
Eslam Afifi
modified on Saturday, March 14, 2009 12:09 PM
|
|
|
|
|
Set project Output Type to Class Library, then you wont need Main
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Xmen is right, but, of course, your code will not then execute, it will need to be imported into a project that DOES have a main method, which then will create instances of these classes and call them. There is no way to get C# code to execute without a static void main method, somewhere, unless it is in a class library that uses COM and thus can be loaded by a C++ app ( which would have an int main method ).
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Simple, write a compiler that uses a different name.
|
|
|
|
|
Hi,
I have the client and Udp server communicate with each other.Now im not getting the exception "The existing connection was forcibly closed by the remote host".This is because i have defined the server in a separate project.
The client is now able to communicate with 1 server at one ip and port.But i want the client to call another udp server at another port but same ip.For eg:the client is communicating with udp server at port 10001.After every 15 secs the client should connect with the servers at different ports(10002,10003 etc)
How i can do this?Please give me your suggestions
|
|
|
|
|
Hi,
what could be the problem? duplicate what you already have. And if there are any blocking calls, consider using an extra thread/backgroundworker.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
"Hi, I have the client and Udp server communicate with each other.Now im not getting the exception "The existing connection was forcibly closed by the remote host".This is because i have defined the server in a separate project."
- Most likely because you are using UDP and not TCP (if thats what was used before) UDP doesnt care about "connections" etc, it just sends/recieves to/from endpoints. Not because you moved the server part into a seperate project...
"The client is now able to communicate with 1 server at one ip and port.But i want the client to call another UDP server at another port but same ip.For eg:the client is communicating with udp server at port 10001.After every 15 secs the client should connect with the servers at different ports(10002,10003 etc)"
- You will have to define another endpoint for the UDP sending socket (client) with a different port, tis all. If you still are having problems, please post up some code; it might help clear things up.
modified on Saturday, March 14, 2009 1:30 PM
|
|
|
|
|
Hi,
If iam defining a new endpoint the client will be able to call yet another udp server.But i want the client to recursively call the servers at different port for every 15 secs.
//client
private void SendMessage()
{
try
{
listBox6.Items.Add("Connecting....");
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10001);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, 1);
listBox6.Items.Add("Connected");
byte[] data = new byte[1024];
String snd = "hello";
data = Encoding.ASCII.GetBytes(snd);
listBox6.Items.Add("Transmitting...");
sock.SendTo(data, 0,data.Length, SocketFlags.None, ipep);
listBox6.Items.Add("Sent...");
EndPoint tmpRemote = (EndPoint)ipep;
listBox6.Items.Add("Message received from {0}:");
listBox6.Items.Add(ipep.ToString());
data = new byte[1024];
int recv = sock.ReceiveFrom(data, 0, data.Length, SocketFlags.None, ref tmpRemote);
String zz=Encoding.ASCII.GetString(data, 0, recv);
listBox6.Items.Add(zz);
if (zz == "Welcome to the Server")
{
lb9.Text = "Active";
lb9.BackColor = Color.Green;
}
else{
lb9.Text = "Inactive";
lb9.BackColor=Color.Red;
}
}
catch (SocketException e)
{
MessageBox.Show(e.Message);
}
}
//server
public static void start_server()
{
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10001);
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
newsock.Bind(ipep);
Console.WriteLine("Waiting for a client...");
while (true)
{
try
{
EndPoint tmpRemote = (EndPoint)ipep;
byte[] data = new byte[1024];
Console.WriteLine("hai");
int recv = newsock.ReceiveFrom(data, 0, data.Length, SocketFlags.None, ref tmpRemote);
Console.WriteLine("gfgjfk");
Console.WriteLine("Message received from {0}:", tmpRemote.ToString());
Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
data = new byte[1024];
string ss = "Welcome to the Server";
data = Encoding.ASCII.GetBytes(ss);
newsock.SendTo(data, 0, data.Length, SocketFlags.None, tmpRemote);
Console.WriteLine("\nSent Acknowledgement");
}
catch (SocketException e)
{
Console.WriteLine(e.Message);
}
start_server();
}
}
}
|
|
|
|
|
did you try my last[^] suggestion?
|
|
|
|
|
Hi,
I used multithreading concept so the client is able to communicate with any number of servers.Using the same concept i tried to call the 2nd server after 10 secs.When it comes to the client the 2nd time it gives"Invalid OperationException Cross-thread operation not valid: Control 'listBox6' accessed from a thread other than the thread it was created on."
//server
public UdpServer()
{
try
{
Thread startServer = new Thread(new ThreadStart(start_server));
startServer.Start();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
try
{
Thread.Sleep(10000);
startServer2 = new Thread(new hreadStart(start_server2));
startServer2.Start();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
public static void start_server()
{
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10001);
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
newsock.Bind(ipep);
Console.WriteLine("Waiting for a client...");
while (true)
{
try
{
EndPoint tmpRemote = (EndPoint)ipep;
byte[] data = new byte[1024];
Console.WriteLine("hai");
int recv = newsock.ReceiveFrom(data, 0, data.Length, SocketFlags.None, ref tmpRemote);
Console.WriteLine("gfgjfk");
Console.WriteLine("Message received from {0}:", tmpRemote.ToString());
Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
data = new byte[1024];
string ss = "Welcome to the Server";
data = Encoding.ASCII.GetBytes(ss);
newsock.SendTo(data, 0, data.Length, SocketFlags.None, tmpRemote);
Console.WriteLine("\nSent Acknowledgement");
}
catch (SocketException e)
{
Console.WriteLine(e.Message);
}
}
}
public static void start_server2()
{
IPEndPoint ipep1 = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10002);
Socket newsock1 = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
newsock1.Bind(ipep1);
Console.WriteLine("Waiting for a client2...");
while (true)
{
try
{
EndPoint tmpRemote1 = (EndPoint)ipep1;
byte[] data = new byte[1024];
Console.WriteLine("hai");
int recv = newsock1.ReceiveFrom(data, 0, data.Length, SocketFlags.None, ref tmpRemote1);
Console.WriteLine("gfgjfk");
Console.WriteLine("Message received from {0}:", tmpRemote1.ToString());
Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
data = new byte[1024];
string ss = "Welcome to the Server";
data = Encoding.ASCII.GetBytes(ss);
newsock1.SendTo(data, 0, data.Length, SocketFlags.None, tmpRemote1);
Console.WriteLine("\nSent Acknowledgement");
}
catch (SocketException e)
{
Console.WriteLine(e.Message);
}
}
} //client
private void SendMessage()
{
try
{
listBox6.Items.Add("Connecting....");
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10001);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, 1);
listBox6.Items.Add("Connected");
byte[] data = new byte[1024];
String snd = "hello";
data = Encoding.ASCII.GetBytes(snd);
listBox6.Items.Add("Transmitting...");
sock.SendTo(data, 0,data.Length, SocketFlags.None, ipep);
listBox6.Items.Add("Sent...");
EndPoint tmpRemote = (EndPoint)ipep;
listBox6.Items.Add("Message received from {0}:");
listBox6.Items.Add(ipep.ToString());
data = new byte[1024];
int recv = sock.ReceiveFrom(data, 0, data.Length, SocketFlags.None, ref tmpRemote);
String zz=Encoding.ASCII.GetString(data, 0, recv);
listBox6.Items.Add(zz);
if (zz == "Welcome to the Server")
{
lb9.Text = "Active";
lb9.BackColor = Color.Green;
}
else{
lb9.Text = "Inactive";
lb9.BackColor=Color.Red;
}
}
catch (SocketException e)
{
MessageBox.Show(e.Message);
}
}
private void SendMessage1()
{
try
{
listBox6.Items.Add("Connecting....");
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10002);
}} I am calling the SendMessage1 in a timer event
[code] private void tim_Elapsed(object sender,ElapsedEventArgs e)
{
SendMessage1();
}
Please help me with this
modified on Sunday, March 15, 2009 4:13 AM
|
|
|
|
|
Hi
The following code gives me the output:
Waiting for client...
hai
Waiting for client2.....
hai
Message received from...
hello
Sent ackn....
hai
Message received from...
server
Sent ackn....
I want it to be like:
Waiting for client...
hai
Message received from...
hello
Sent ackn....
Waiting for client 2...
I tried to change but im getting"the existing connection was forcibly closed by the remote host"..Please help me with this
//client
public void SendMessage()
{
try
{
listBox6.Items.Add("Connecting....");
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10001);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
sock.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, 1);
listBox6.Items.Add("Connected");
byte[] data = new byte[1024];
String snd = "hello";
data = Encoding.ASCII.GetBytes(snd);
listBox6.Items.Add("Transmitting...");
sock.SendTo(data, 0,data.Length, SocketFlags.None, ipep);
listBox6.Items.Add("Sent...");
EndPoint tmpRemote = (EndPoint)ipep;
listBox6.Items.Add("Message received from {0}:");
listBox6.Items.Add(ipep.ToString());
data = new byte[1024];
int recv = sock.ReceiveFrom(data, 0, data.Length, SocketFlags.None, ref tmpRemote);
String zz=Encoding.ASCII.GetString(data, 0, recv);
listBox6.Items.Add(zz);
if (zz == "Welcome to the Server")
{
lb9.Text = "Active";
lb9.BackColor = Color.Green;
}
else{
lb9.Text = "Inactive";
lb9.BackColor=Color.Red;
}
}
catch (SocketException e)
{
MessageBox.Show(e.Message);
}
}
public void SendMessage1()
{
}
//server
public UdpServer()
{
try
{
startServer = new Thread(new ThreadStart(start_server));
startServer.Start();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
startServer.Abort();
}
try
{
startServer2 = new Thread(new ThreadStart(start_server2));
startServer2.Start();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
startServer2.Abort();
}
}
public static void start_server()
{
IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 10001);
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
newsock.Bind(ipep);
Console.WriteLine("Waiting for a client...");
while (true)
{
try
{
EndPoint tmpRemote = (EndPoint)ipep;
byte[] data = new byte[1024];
Console.WriteLine("hai");
int recv = newsock.ReceiveFrom(data, 0, data.Length, SocketFlags.None, ref tmpRemote);
Console.WriteLine("gfgjfk");
Console.WriteLine("Message received from {0}:", tmpRemote.ToString());
Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
data = new byte[1024];
string ss = "Welcome to the Server";
data = Encoding.ASCII.GetBytes(ss);
newsock.SendTo(data, 0, data.Length, SocketFlags.None, tmpRemote);
Console.WriteLine("\nSent Acknowledgement"); }
catch (SocketException e)
{
Console.WriteLine(e.Message);
}
}
}
public static void start_server2()
{
}
|
|
|
|
|
Hi
I used the Thread.Sleep()
public UdpServer()
{
try
{
startServer = new Thread(new ThreadStart(start_server));
startServer.Start();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
try
{
Thread.Sleep(20000);
startServer2 = new Thread(new ThreadStart(start_server2));
startServer2.Start();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
} Im getting the output as
Waiting for client...
hai
Message received....
hello
Sent ack
Waiting for client2...
hai
At this it shows"existing connection was forcibly closed by the remote host".Please give me your suggestion
|
|
|
|
|
I have made some user controls. I will be using them in another application in C# where these will be added on the form dynamically at the click of a button. The sizes of the user controls differ from one another.
The problem is that when I add them dynamically it aligns itself at the top left corner. I want it to automatically align itself to centre of the main form and when I resize the form, it should realign itself.
I have tried setting its dock property to fill but it doesn't help at all.
Always Keep Smiling.
Yours Pankaj Nikam
|
|
|
|
|
use Resize event of form and put all controls in a panel then update its location. eg
panel.Location = new Point(this.Width/2 - panel.Width/2, this.Height/2-panel.Height/2);
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Thank you so much.
Always Keep Smiling.
Yours Pankaj Nikam
|
|
|
|
|
Put everything into a panel, and set that panel's Anchor property to none.
|
|
|
|
|
Hey all,
I am currently in the middle of writing a custom windows form. (.Net 2.0).
I have removed the default border from the form, changed this to a Sizable Border and also set the text of the form to blank so to remove the window caption box.
I have now added a custom close, minimize, and maximize button to my form. All works well except for the maximize. On clicking this button, i do wish the form to maximize, which it does, however; it also maxmizes over the top of the task bar. How would i go about stopping this, and letting us view the task bar at all times?
I could set the size on the window, however; that would still show the resize borders on the form, which i want to be hidden on maximized state.
Help would be greatly appreciated.
Thanks
TF
|
|
|
|
|
If this.WindowState = System.Windows.Forms.FormWindowState.Maximized doesn't work for you then you're working too hard.
|
|
|
|
|