Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 1st, 2008, 12:04 AM
Friend of Wrox
 
Join Date: Mar 2008
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.

 
Old April 1st, 2008, 09:48 PM
Friend of Wrox
 
Join Date: Mar 2008
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.

 
Old April 2nd, 2008, 03:27 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
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 -/
 
Old April 2nd, 2008, 05:27 PM
Friend of Wrox
 
Join Date: Mar 2008
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.






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 01:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.