Click here to Skip to main content
16,005,316 members
Home / Discussions / C#
   

C#

 
GeneralRe: Asp .net gantt chart control Pin
shruPrasad30-Jan-09 0:07
shruPrasad30-Jan-09 0:07 
GeneralTogle acheckbox Pin
picasso27-Jan-05 18:06
picasso27-Jan-05 18:06 
GeneralRe: Togle acheckbox Pin
Matt Gerrans7-Jan-05 20:53
Matt Gerrans7-Jan-05 20:53 
GeneralRe: Togle acheckbox Pin
Luis Alonso Ramos8-Jan-05 12:34
Luis Alonso Ramos8-Jan-05 12:34 
GeneralAnyone know any good resources (besides codeproject :P) that deal with collections for use in custom controls Pin
FocusedWolf7-Jan-05 17:46
FocusedWolf7-Jan-05 17:46 
GeneralRe: Anyone know any good resources (besides codeproject :P) that deal with collections for use in custom controls Pin
ACorbs8-Jan-05 9:33
ACorbs8-Jan-05 9:33 
GeneralRe: Anyone know any good resources (besides codeproject :P) that deal with collections for use in custom controls Pin
FocusedWolf8-Jan-05 16:48
FocusedWolf8-Jan-05 16:48 
GeneralForm and Network Listener Pin
Jackson L7-Jan-05 16:05
sussJackson L7-Jan-05 16:05 
I am a newbie to C# so please excuse if this problem is really something simple.

I am trying to create an app that sets a window to maximized state after it recieves a certain command over a TCP port. I can get the tcp listener to work but I cant get the form to display. The form never even shows up. I only get the runtime error "Object reference not set to an instance of an object" after I enter the command via the network to set the form to maximized. I think the problem has to do with my calling a method from within the constructor when the constructor has not yet finished. I have attached my code if anyone is willing to look and suggest where I might find where I am going wrong.



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;

namespace networkScreenBlanker
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.Run();

//
// TODO: Add any constructor code after InitializeComponent call
//
}


///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
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()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;

}
#endregion



private void Run()
{
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
TcpListener tcpListener = new TcpListener(localAddr, 65000);
tcpListener.Start();

for(;;)
{
Socket socketForClient = tcpListener.AcceptSocket();
if (socketForClient.Connected)
{
//Console.WriteLine("Client connected");

//SendFileToClient(socketForClient);
NetworkStream networkStream = new NetworkStream(socketForClient);
System.IO.StreamReader streamReader = new System.IO.StreamReader(networkStream);
string inputString;
inputString = streamReader.ReadLine();
if (inputString != null)
{
if (inputString == "blankScreen")
{
Form1.ActiveForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;

}

//Console.WriteLine("Disconnecting from client...");

socketForClient.Close();
//Console.WriteLine("Exiting...");
break;
}
}
}
}

//[STAThread]
public static void Main()
{
Application.Run(new Form1());


}

}
}
GeneralRe: Form and Network Listener Pin
Allan Eagle8-Jan-05 14:40
Allan Eagle8-Jan-05 14:40 
GeneralRe: Form and Network Listener Pin
Member 14535649-Jan-05 15:45
Member 14535649-Jan-05 15:45 
QuestionWindows Forms question: How to lock scrollbars? Pin
kmansari7-Jan-05 14:33
kmansari7-Jan-05 14:33 
GeneralWeb-Services with a Collection of a custom object Pin
He11razor7-Jan-05 13:54
He11razor7-Jan-05 13:54 
GeneralRe: Web-Services with a Collection of a custom object Pin
Andy Brummer7-Jan-05 17:18
sitebuilderAndy Brummer7-Jan-05 17:18 
Generalwindows socket Pin
WaleedH7-Jan-05 11:16
WaleedH7-Jan-05 11:16 
GeneralRe: windows socket Pin
Alex Korchemniy7-Jan-05 11:26
Alex Korchemniy7-Jan-05 11:26 
GeneralRe: windows socket Pin
kmansari7-Jan-05 14:30
kmansari7-Jan-05 14:30 
Generalwindows socket Pin
ghjhgjghjghj7-Jan-05 11:16
sussghjhgjghjghj7-Jan-05 11:16 
GeneralRe: windows socket Pin
MoustafaS8-Jan-05 1:17
MoustafaS8-Jan-05 1:17 
GeneralRe: windows socket Pin
Alex Korchemniy8-Jan-05 5:37
Alex Korchemniy8-Jan-05 5:37 
GeneralPowerPoint automation question Pin
Asad Hussain7-Jan-05 11:00
Asad Hussain7-Jan-05 11:00 
GeneralRe: PowerPoint automation question Pin
Alex Korchemniy7-Jan-05 11:12
Alex Korchemniy7-Jan-05 11:12 
Questionpressure clock ?? Pin
Sakkijha7-Jan-05 10:46
Sakkijha7-Jan-05 10:46 
AnswerRe: pressure clock ?? Pin
Alex Korchemniy7-Jan-05 11:18
Alex Korchemniy7-Jan-05 11:18 
GeneralRe: pressure clock ?? Pin
Sakkijha8-Jan-05 4:47
Sakkijha8-Jan-05 4:47 
GeneralRe: pressure clock ?? Pin
Alex Korchemniy8-Jan-05 5:33
Alex Korchemniy8-Jan-05 5:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.