Use MSN Instant Messenger software in Vs.net (next)

Source: Internet
Author: User
Tags bool header
Receive Message

The way to determine if a new message is received is if the content is a "text" type, and the code is as follows

private void ontextrecieved (Messenger.imsgrimsession s,
Messenger.imsgruser u, string header, string text,
ref bool default)
{
if (header. IndexOf ("Content-type:text/plain")!=-1 &&
U.friendlyname!= "Hotmail")
{
Messagewindow.appendtext (U.friendlyname + ":" + text + "\ r \ n");
CurrentUser = u;
default = FALSE;
}
}


Send a message

Enter the message you want to send to the edit box, and then click the Send button, and the contents of the edit box will be sent by the following code:

private static String Header =
"Mime-version:1.0\r\ncontent-type:text/plain;" +
"Charset=utf-8\r\nx-mms-im-format:" +
"FN=MS%20SHELL%20DLG; ef=; co=0; cs=0; Pf=0\r\n\r\n ";

private void Send_click (object sender, System.EventArgs e)
{
Currentuser.sendtext (header, This.sendText.Text,
Messenger.MMSGTYPE.MMSGTYPE_ALL_RESULTS);

Messagewindow.appendtext ("You say:" + Sendtext.text + "\ r \ n");
}


Update the status of a contact

I used a different icon in the ListView to indicate the corresponding state of the contact. When the constructor is invoked, the status of the contact is set for the first time. Call the Onuserstatuschanged () event to update the status of the contact when the contact state changes.

private void onuserstatechanged (Messenger.imsgruser user,
Messenger.mstate State, ref bool default)
{
for (int i = 0; i < Users.count; i++)
{
if (user = = Users.item (i))
{
ListViewItem item = Userlist.items[i];
Item. ImageIndex = getstateimage (user. State);
}
}
}


Summary

I hope that you will be interested in this article, through this article we also understand a small number of MSN features. MSN has a lot of other functions and so we go to dig. Ok, now we know that creating vs.net add-ins is an easy thing to do, and you can create more creative add-ins from this.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.