Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 1st, 2008, 12:04 AM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default Instant Messenger Trouble with Message Window

I have the main form of my program holding the code to log in to MSN, YAHOO, ICQ, and AIM, i can log in, i can see my friend list in the treeview object, and when i click their names i can get a chat window to come up. its great. but i can not send messages to them because the code for the neccessary calls is accessesible from the form1 class. I need a way for my SendMessageButton_Click to be able to access the myMSN object(thats where the calls are, from the FastIM_MSN class and myMSN is an instance of it. i need myMSN.SendMessage() accessible from the class that creates the window that holds the conversation. i hope i was clear, i am tired, its about time for me to get those 8 hours in lol.

  #2 (permalink)  
Old April 1st, 2008, 09:48 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

i have
private void tvMSNContacts_DoubleClick(object sender, TreeViewEventArgs e)
        {
            Multim_MSN_ msnSession = new Multim_MSN_();
            msnSession.SetSessionTitle(e.Node.Text + " Message Session");
            msnSession.Show();
        }
and the compiler says:
Error 5 No overload for 'tvMSNContacts_DoubleClick' matches delegate 'System.EventHandler' C:\Documents and Settings\David\Desktop\C#\Multim Messenger\Multim Messenger\Form1.Designer.cs 453

its set up to take the two default arguements:
object sender, EventArgs e
i want it to take:
object sender, TreeViewEventArgs e

also, if anyone knows my bigger problem, i have my mainform for my IM set up, when i click my contacts name, a window comes up so i can type and recieve messages, i have functions for my session window class to set the title based on the contacts name, i can send the incoming messages to the session windows textbox that holds the 2way conversation's messages, but i cant send messages because i do not know how to make my SessionWin class gain access to the myMSNMessenger class instance (this class holds all the data for connecting, disconnecting, sending, recieving messages, loading contacts and putting them into groups, and so on...) in my main form. i need to access this object so when i click the session windows send button i have acess to the SendMessage function, i cant make a separate myMSNMessenger object in my SessionWin class because that object logs me in and i cant log in twice. is it possible to pass a function as a param? can i pass the SendMessageFunction as a param to my btnSendMessage_OnClick event method? i hope i make sense, this is kind of hard for me to explain.

  #3 (permalink)  
Old April 2nd, 2008, 03:27 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,133
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You might 'want' it to take TreeViewEventArgs but I think it is quite obvious that it wont. Just check the node tree's currently selected node if you want the current node.

Also, regarding you other problem - it might be best if you create your 'MSN' object using something called the Singleton pattern.

[code]

Code:
public class MsnInstance
{
    private static Multim_MSN_  _msnInstance = null;

    public static Multim_MSN_ GetInstance()
    {
        if( _msnInstance == null ) 
        {
            _msnInstance = new Multim_MSN_();
        {
        return _msnInstance;    
    }
}
Then in your code anywhere you want to use it you just do the following:

Code:
Multim_MSN_ myInstance = MsnInstance.GetInstance();
/- Sam Judson : Wrox Technical Editor -/
  #4 (permalink)  
Old April 2nd, 2008, 05:27 PM
Friend of Wrox
 
Join Date: Mar 2008
Location: So Cal is good enough for you, California, USA.
Posts: 133
Thanks: 15
Thanked 1 Time in 1 Post
Send a message via ICQ to iceman90289 Send a message via AIM to iceman90289
Default

Thanks, i got the class made and i will see how it works when my brother gets finished typing his essay. lol.

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
instant messenger like - outlook addin maricar C# 0 September 10th, 2008 07:52 PM
i want to make an instant message that... iceman90289 C# 2005 3 March 28th, 2008 03:33 PM
MSN / Yahoo messenger like pop up window tact_259 General .NET 4 May 12th, 2004 02:30 PM
Instant Messenger asims12 Classic ASP Basics 0 November 9th, 2003 12:26 AM



All times are GMT -4. The time now is 03:01 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.