Chat application - opening chat window

not as noob as it sounds, or is it?

Page 1 of 1

2 Replies - 6300 Views - Last Post: 12 October 2007 - 06:23 AM Rate Topic: -----

#1 fxitsolutions  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-October 07

Chat application - opening chat window

Posted 12 October 2007 - 05:57 AM

I'm trying to make a chat program like MSN messenger, ive made the login screen and thats all working fine, i've got a simple chat window called chatwindow. The thing im having problems with is opening new chat windows.

In my chat program main form i have a dynamic list of contacts saved in a database on the clients PC. The only problem is that I dont know how to open a new chat window dynamically to start chatting to the person they clicked on.

All i can do is open the form using
chatwindow.show();
but the window doesnt know who to chat to! Is there anyway of passing even a variable onto the chatWindow form?

There are no in-depth chat program tutorials on the internet that I can find, only ones that use streamreader etc. I have a feeling the solution is incrediably simple, but its been driving me nuts.

Cheers.

Is This A Good Question/Topic? 0
  • +

Replies To: Chat application - opening chat window

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1633
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Chat application - opening chat window

Posted 12 October 2007 - 06:14 AM

Creating a chat application is not a simple process. You have to use :

All are in the System.Net.Sockets Namespace. I have created a tutorial on creating a Basic client/server chat application in C# but you would have to make some modification to it to fit what you need.

So unfortunately the solution for creating a chat application isnt a simple one. Now opening your chat window passing a variable to it is simple, but actually being able to chat with someone is going to take quite a bit of work (I know, I created one for work).

Now for your question, to open your chat window passing a variable to it, the easiest way is to create a public variable on your chat window form:

private string _nickName
public string NickName
{
	  get { return _nickName; }
	  set {_nickName = value; }
}



Then in the double click event of your ListBox (I assume thats what you're using to hold the nicknames) set the property of your other form before opening it

Form2 f2 = new Form2();
f2.NickName = YourListBoxValue;
f2.Show();



Hope that helps at least a little :)
Was This Post Helpful? 0
  • +
  • -

#3 fxitsolutions  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 01-October 07

Re: Chat application - opening chat window

Posted 12 October 2007 - 06:23 AM

OMG perfect cheers! I already have a working chat app, just need to dynamically get the IP's of the clients.

Thanks man.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1