<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type='text/xsl' href='http://msnwindowslive.spaces.live.com/mmm2008-07-24_12.50/rsspretty.aspx?rssquery=en-US;http%3a%2f%2fmsnwindowslive.spaces.live.com%2ffeed.rss' version='1.0'?><rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:msn="http://schemas.microsoft.com/msn/spaces/2005/rss" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>MSN and Windows Live</title><description>Tips, tricks and information regarding MSN and Windows Live. See also http://hackersoftmvp.spaces.live.com/</description><link>http://MSNWindowsLive.spaces.live.com/</link><language>en-US</language><pubDate>Mon, 13 Oct 2008 19:11:13 GMT</pubDate><lastBuildDate>Mon, 13 Oct 2008 19:11:13 GMT</lastBuildDate><generator>Microsoft Spaces v1.1</generator><docs>http://www.rssboard.org/rss-specification</docs><ttl>60</ttl><live:identity><live:id>-2719028481651278955</live:id><live:alias>MSNWindowsLive</live:alias></live:identity><image><title>MSN and Windows Live</title><url>http://byfiles.storage.live.com/y1p2uldQmpH73KCl4ifQ0xHH0h7k-YD0V-l7oKGJs8V-NaHrzz7mpbz3hqCN_ebHaXZ</url><link>http://MSNWindowsLive.spaces.live.com/</link></image><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="typelabel" label="Type" /><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="tag" label="Tag" /><cf:group element="category" label="Category" /><cf:sort element="pubDate" label="Date" data-type="date" default="true" /><cf:sort element="title" label="Title" data-type="string" /><cf:sort ns="http://purl.org/rss/1.0/modules/slash/" element="comments" label="Comments" data-type="number" /></cf:listinfo><item><title>Creating a Web Messenger control from Scratch – Part 7</title><link>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!786.entry</link><description>&lt;div style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Windows+Live" rel=tag&gt;Windows Live&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Messenger" rel=tag&gt;Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Windows+Live+Messenger" rel=tag&gt;Windows Live Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/API" rel=tag&gt;API&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Messenger+API" rel=tag&gt;Messenger API&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Programming" rel=tag&gt;Programming&lt;/a&gt;, &lt;a href="http://technorati.com/tags/How+to" rel=tag&gt;How to&lt;/a&gt;&lt;/div&gt; &lt;h4&gt;&lt;strong&gt;Corrections&lt;/strong&gt;&lt;/h4&gt; &lt;p&gt;Before moving onto the next part of the Web Messenger User Control, I was running through the code I have developed so far and happened upon a couple of bugs, so this part of the Web Messenger User Control tutorial will be a short one fixing the bugs in the code we have so far. &lt;p&gt;On fixing these bugs the User Control works as expected and you end up with something akin to the following :- &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pyGyQ7GzqR_bfx4eCTSC6Q9xzm1cr7B1k1G1mgUEcT79u7NhpnTBeu0XqYCgZ503T?PARTNER=WRITER"&gt;&lt;img title=MessUserControl style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=118 alt=MessUserControl src="http://byfiles.storage.msn.com/y1pojygxG3tL5aCWmbr5Jp8UqWV8cjo60JJEcgoqbL6N8uGc8KyfWnSlkdZpmZnacBcR_I9VKNvr9Q?PARTNER=WRITER" width=339 border=0&gt;&lt;/a&gt;  &lt;p&gt;Both of the bugs appear in the displayUserInfo() function, and following onto that there have been changes made to the getSignInCode() function as well. &lt;p&gt;The first bug is to do with displaying the user’s stored picture. In my original code, I retrieved the Image by using the get_displayPictureUrl() property of the Presence class. Then I checked for a valid file extension using the following code :-&lt;pre&gt;&lt;/pre&gt;
&lt;p&gt;var userPicLast3 = userPicture.substr(userPicture.length - 3);
&lt;p&gt;var pic = new Image();
&lt;p&gt;if (userPicLast3 !== &amp;quot;jpg&amp;quot; &amp;amp;&amp;amp; userPicLast3 !== &amp;quot;gif&amp;quot; &amp;amp;&amp;amp; userPicLast3 !== &amp;quot;png&amp;quot;)
&lt;p&gt;{
&lt;p&gt;    pic.src = &amp;quot;WebMessenger/Images/MsgrNoImage.gif&amp;quot;;
&lt;p&gt;}
&lt;p&gt;else
&lt;p&gt;{    
&lt;p&gt;    pic.src = userPicture;
&lt;p&gt;    pic.onerror = function()
&lt;p&gt;    {
&lt;p&gt;        pic.src = &amp;quot;WebMessenger/Images/MsgrNoImage.gif&amp;quot;;
&lt;p&gt;    }
&lt;p&gt;}
&lt;p&gt;This code is incorrect as the DisplayPictureUrl() property will never return a file extension, therefore when running the code you would always end up with the default image and never get the user’s actual display image.  This code should be removed and replaced with :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userPicture = msgruser.get_presence().get_displayPictureUrl();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; img = &lt;span style="color:blue"&gt;new&lt;/span&gt; Image();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;img.onerror = &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    img.src = &lt;span style="color:#a31515"&gt;&amp;quot;WebMessenger/Images/MsgrNoImage.gif&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;img.src = userPicture;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:green"&gt;//Now we need to scale the image down to 40 pixels width&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:green"&gt;//and the appropriate height&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; scale = Math.round(img.width / 40);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;img.style.width = &lt;span style="color:#a31515"&gt;&amp;quot;40&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;img.style.height = Math.round(img.height / scale)&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Here we again use the DisplayPictureUrl() property however we assign this directly to a new Image() object which will render correctly. Just in case it doesn’t we put an onerror condition in to point to our default image. Reasons for it not rendering correctly can be things like the user hasn’t actually assigned themselves an image and therefore the property call returns null, the user has a specialized animated for messenger (like I do for one of my accounts) etc.
&lt;p&gt;Since we now have an actual image object and are not just creating an &amp;lt;img&amp;gt; html tag, we need to change certain things in our getSignInCode() function. We no longer pass in the img.src attribute as we did before and instead just assign a placeholder in which we will put the image :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; getSignInCode(userName, userMessage, userStatus, MailMessages)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//This is basically a guess. Because we can't assume the user has a hotmail.com&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//inbox as Live ID allows for non-hotmail accounts, we are assuming that the&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//users email can be found at the address following the @.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//e.g. abc@gmail.com - take the part after the @, add www and you end up with&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;      &lt;span style="color:green"&gt;//www.gmail.com&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; EmailAddress = msgruser.get_address().get_address();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; Email = &lt;span style="color:#a31515"&gt;&amp;quot;http://www.&amp;quot;&lt;/span&gt; + EmailAddress.substr(EmailAddress.indexOf(&lt;span style="color:#a31515"&gt;&amp;quot;@&amp;quot;&lt;/span&gt;) + 1);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; PendingContacts = msgruser.get_pendingContacts().get_count();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; result = &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;table width='100%'&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td rowspan='2' width='42px' style='padding: 2px; background-color: &amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;if&lt;/span&gt; (userStatus.toLowerCase() == &lt;span style="color:#a31515"&gt;&amp;quot;online&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#00cc00;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt; &lt;span style="color:blue"&gt;if&lt;/span&gt; (userStatus.toLowerCase() == &lt;span style="color:#a31515"&gt;&amp;quot;offline&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#cc0000;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#E3AC4F;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;      &lt;span style="color:green"&gt;//A placeholder for the users picture&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;'&amp;gt;&amp;lt;div id='userPic'&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td align='center'&amp;gt;&amp;lt;span style='font-weight: bold; font-family: Tahoma,arial,sans-serif; font-size:12px;'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += userName;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td width='24px' style='padding: 2px; a:visited: #000000; a:hover: #ffffff; a:link: #000000;'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;a href='&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += Email;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;' target='_blank' &amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;img src='WebMessenger/Images/Mail.gif' style='border: 0px;' /&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;span style='font-weight: bold; text-decoration: none;'&amp;gt;&amp;amp;nbsp;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += MailMessages;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += userMessage;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td style='padding: 2px; a:visited: #000000; a:hover: #ffffff; a:link: #000000;'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;a href='javascript:PendingContacts();'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;img src='WebMessenger/Images/PendingContact.gif' style='border: 0px;' /&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;span style='font-weight: bold; text-decoration: none;' id='PendingContacts'&amp;gt;&amp;amp;nbsp;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += PendingContacts;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;Now since this hasn’t been added to the document/page yet, we cannot get a reference to the “userPic” div that we have created and therefore cannot insert the image. So we need to wait until this has been added using the innerHTML first. Here is the full working code for the displayUserInfo() function :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:green"&gt;/* Populate the user information string. */&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; displayUserInfo()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userInfo = $get(&lt;span style="color:#a31515"&gt;'userInfo'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userAddress = msgruser.get_address().get_address();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userDispName = msgruser.get_presence().get_displayName();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userPersonalMessage = msgruser.get_presence().get_personalMessage();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userPicture = msgruser.get_presence().get_displayPictureUrl();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; img = &lt;span style="color:blue"&gt;new&lt;/span&gt; Image();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    img.onerror = &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        img.src = &lt;span style="color:#a31515"&gt;&amp;quot;WebMessenger/Images/MsgrNoImage.gif&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    img.src = userPicture;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//Now we need to scale the image down to 40 pixels width&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//and the appropriate height&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; scale = Math.round(img.width / 40);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    img.style.width = &lt;span style="color:#a31515"&gt;&amp;quot;40&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    img.style.height = Math.round(img.height / scale)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userStatus = Enum.toString(Microsoft.Live.Messenger.PresenceStatus, msgruser.get_presence().get_status());&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userName = &lt;span style="color:blue"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;if&lt;/span&gt; (userDispName !== &lt;span style="color:#a31515"&gt;''&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        userName = userDispName + &lt;span style="color:#a31515"&gt;' ('&lt;/span&gt; + userAddress + &lt;span style="color:#a31515"&gt;'): '&lt;/span&gt; + userStatus;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        userName = userAddress + &lt;span style="color:#a31515"&gt;': '&lt;/span&gt; + userStatus;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//Get the number of unopened mail messages&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; Mail = msgruser.get_mailbox().get_inboxUnreadCount();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userDisplay = getSignInCode(userName, userPersonalMessage, userStatus, Mail);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;      &lt;span style="color:green"&gt;//First clear the userInfo display area&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    removeChildrenFromNode(&lt;span style="color:#a31515"&gt;'userInfo'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    userInfo.innerHTML = userDisplay;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    document.getElementById(&lt;span style="color:#a31515"&gt;'personalMessage'&lt;/span&gt;).value = userPersonalMessage;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//Now that the users Information is displayed, the placeholder for their&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//picture is available and we can insert it.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    document.getElementById(&lt;span style="color:#a31515"&gt;'userPic'&lt;/span&gt;).appendChild(img);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;As you can see, the last line of this function actually inserts the image onto the page. 
&lt;p&gt;The second bug was that I called the wrong property to check whether the user had any unread in their inbox. The actual call I used was :-
&lt;p&gt;var Mail = msgruser.get_mailbox().get_inboxInitialCount();
&lt;p&gt;This gets the total number of emails from the user’s inbox, not their unread amount. The actual property I should have called is :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; Mail = msgruser.get_mailbox().get_inboxUnreadCount();&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;This is reflected in the updated displayUserInfo() function above. If you’ve been following along, simply replace these two functions with the code above and you’re good to go. Next we will be taking a look at Contacts.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-2719028481651278955&amp;page=RSS%3a+Creating+a+Web+Messenger+control+from+Scratch+%e2%80%93+Part+7&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=msnwindowslive.spaces.live.com&amp;amp;GT1=MSNWindowsLive"&gt;</description><category>Programming</category><comments>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!786.entry#comment</comments><guid isPermaLink="true">http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!786.entry</guid><pubDate>Tue, 07 Oct 2008 19:42:34 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://MSNWindowsLive.spaces.live.com/blog/cns!DA44120081017B95!786/comments/feed.rss</wfw:commentRss><wfw:comment>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!786.entry#comment</wfw:comment><dcterms:modified>2008-10-07T19:42:34Z</dcterms:modified></item><item><title>Creating a Web Messenger control from Scratch – Part 6</title><link>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!783.entry</link><description>&lt;div style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Windows+Live" rel=tag&gt;Windows Live&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Web+Messenger" rel=tag&gt;Web Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Windows+Live+Web+Messenger" rel=tag&gt;Windows Live Web Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Programming" rel=tag&gt;Programming&lt;/a&gt;, &lt;a href="http://technorati.com/tags/API" rel=tag&gt;API&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Messenger" rel=tag&gt;Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/How+to" rel=tag&gt;How to&lt;/a&gt;&lt;/div&gt; &lt;p&gt;Continuing our series on the Web Messenger control we will take a look at a couple of more API calls you can make and give your control added functionality. &lt;p&gt;Going back to our class there are another couple of properties that are quite interesting :- &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pX2BB4fOZXFULmG6tLGZMtezF-qga_ejC-v1wrDwlWVn9h14fatJCQXZl3NYG-F9h?PARTNER=WRITER"&gt;&lt;img title=MessUserClass style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=402 alt=MessUserClass src="http://byfiles.storage.msn.com/y1peEuT9tZuhgcwSHzy3hCXUsVUlXi9nVEdEpm1itW2ehq4KVB2ApyyPaIf01NQWijue9cVStNe2E0?PARTNER=WRITER" width=99 border=0&gt;&lt;/a&gt;  &lt;p&gt;The first of these is the Mailbox property. The official documentation states that this property “Gets the user's Mailbox”.  Whilst this isn’t the whole truth it does actually give you a few properties that you can work with :- &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pyfl49-KxKJLWqyQG7EEMn961QkyDzZEsdy8aZUhywvvVRS6rPEHqmbDbCtI9-Z91Su_PK2sY3Mw?PARTNER=WRITER"&gt;&lt;img title=MessMailboxProperties style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=107 alt=MessMailboxProperties src="http://byfiles.storage.msn.com/y1pyfl49-KxKJJ-RvGmH5GzH8_ZjQnRtexU8GJkMxxAUA1FjUnm10pIiLnyoVE1R9SjG2v80jIE1nQ?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;ul&gt; &lt;li&gt;InboxInitialCount - Gets the initial mail count of the inbox.  &lt;li&gt;InboxUnreadCount - Gets the current unread mail count of the inbox.  &lt;li&gt;OtherInitialCount - Gets the initial mail count for all folders.  &lt;li&gt;OtherUnreadCount - Gets the current unread mail count for all folders&lt;/ul&gt; &lt;p&gt;As has been stated, what we want to do with this User Control is try to closely match the actual Messenger Client :- &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pXhdXl5EQlKJIhCjAvfQizzfR6hchUt5ZOLyEmU7YhAryXK4M-hKG0t7aE8h9Kt-4RdlPwwZhKUs?PARTNER=WRITER"&gt;&lt;img title=MessClient style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=69 alt=MessClient src="http://byfiles.storage.msn.com/y1p5GsXy6QGspUeEtR9Dirx9N8P69bYbafdJmpzWNcfB_3D5JQNQUQAKHXkHPnNQrzKEXqC0d6Ye2s?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;p&gt;Taking a look at the messenger client, you will see a small envelope in the bottom right. This is an indicator of how many unread emails that you have, and even if you don’t have any, it’s a shortcut to your mailbox. &lt;p&gt;With the properties that are available to us, we can emulate this behavior in our own Messenger Control. &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; displayUserInfo()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userInfo = $get(&lt;span style="color:#a31515"&gt;'userInfo'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userAddress = msgruser.get_address().get_address();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userDispName = msgruser.get_presence().get_displayName();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userPersonalMessage = msgruser.get_presence().get_personalMessage();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userPicture = msgruser.get_presence().get_displayPictureUrl();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    userPicture = userPicture.$0;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userStatus = Enum.toString(Microsoft.Live.Messenger.PresenceStatus, msgruser.get_presence().get_status());&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userPicLast3 = userPicture.substr(userPicture.length - 3);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; pic = &lt;span style="color:blue"&gt;new&lt;/span&gt; Image();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;if&lt;/span&gt; (userPicLast3 !== &lt;span style="color:#a31515"&gt;&amp;quot;jpg&amp;quot;&lt;/span&gt; &amp;amp;&amp;amp; userPicLast3 !== &lt;span style="color:#a31515"&gt;&amp;quot;gif&amp;quot;&lt;/span&gt; &amp;amp;&amp;amp; userPicLast3 !== &lt;span style="color:#a31515"&gt;&amp;quot;png&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        pic.src = &lt;span style="color:#a31515"&gt;&amp;quot;WebMessenger/Images/MsgrNoImage.gif&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {    &lt;/pre&gt;&lt;pre style="margin:0px"&gt;        pic.src = userPicture;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        pic.onerror = &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            pic.src = &lt;span style="color:#a31515"&gt;&amp;quot;WebMessenger/Images/MsgrNoImage.gif&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userName = &lt;span style="color:blue"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;if&lt;/span&gt; (userDispName !== &lt;span style="color:#a31515"&gt;''&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        userName = userDispName + &lt;span style="color:#a31515"&gt;' ('&lt;/span&gt; + userAddress + &lt;span style="color:#a31515"&gt;'): '&lt;/span&gt; + userStatus;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        userName = userAddress + &lt;span style="color:#a31515"&gt;': '&lt;/span&gt; + userStatus;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//Get the number of unopened mail messages&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; Mail = msgruser.get_mailbox().get_inboxInitialCount();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; userDisplay = getSignInCode(pic.src, userName, userPersonalMessage, userStatus, Mail);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;      &lt;span style="color:green"&gt;//First clear the userInfo display area&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    removeChildrenFromNode(&lt;span style="color:#a31515"&gt;'userInfo'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    userInfo.innerHTML = userDisplay;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    document.getElementById(&lt;span style="color:#a31515"&gt;'personalMessage'&lt;/span&gt;).value = userPersonalMessage;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;This is our displayUserInfo function that we went into in the last part of this Web Messenger series. Most of this remains the same however we have changed the signature of the userDisplay() function and added a call into Mailbox properties. The two changes of note are :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:green"&gt;//Get the number of unopened mail messages&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; Mail = msgruser.get_mailbox().get_inboxInitialCount();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userDisplay = getSignInCode(pic.src, userName, userPersonalMessage, userStatus, Mail);&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;The first gets the number of unread emails in the users inbox, and the second calls the userDisplay() function adding the returned value as an input parameter.  Our userDisplay() has now been updated to display the number of unread messages :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; getSignInCode(picUrl, userName, userMessage, userStatus, MailMessages)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//This is basically a guess. Because we can't assume the user has a hotmail.com&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//inbox as Live ID allows for non-hotmail accounts, we are assuming that the&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//users email can be found at the address following the @.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//e.g. abc@gmail.com - take the part after the @, add www and you end up with&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;      &lt;span style="color:green"&gt;//www.gmail.com&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; EmailAddress = msgruser.get_address().get_address();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; Email = &lt;span style="color:#a31515"&gt;&amp;quot;http://www.&amp;quot;&lt;/span&gt; + EmailAddress.substr(EmailAddress.indexOf(&lt;span style="color:#a31515"&gt;&amp;quot;@&amp;quot;&lt;/span&gt;) + 1);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; PendingContacts = msgruser.get_pendingContacts().get_count();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; result = &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;table width='100%'&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td rowspan='2' width='42px' style='padding: 2px; background-color: &amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;if&lt;/span&gt; (userStatus.toLowerCase() == &lt;span style="color:#a31515"&gt;&amp;quot;online&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#00cc00;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt; &lt;span style="color:blue"&gt;if&lt;/span&gt; (userStatus.toLowerCase() == &lt;span style="color:#a31515"&gt;&amp;quot;offline&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#cc0000;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#E3AC4F;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;'&amp;gt;&amp;lt;img width='40px' src='&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += picUrl;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;'&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td align='center'&amp;gt;&amp;lt;span style='font-weight: bold; font-family: Tahoma,arial,sans-serif; font-size:12px;'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += userName;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td width='24px' style='padding: 2px; a:visited: #000000; a:hover: #ffffff; a:link: #000000;'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;a href='&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += Email;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;' target='_blank' &amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;img src='WebMessenger/Images/Mail.gif' style='border: 0px;' /&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;span style='font-weight: bold; text-decoration: none;'&amp;gt;&amp;amp;nbsp;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += MailMessages;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += userMessage;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td style='padding: 2px; a:visited: #000000; a:hover: #ffffff; a:link: #000000;'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Notice the assumption that we are making in comments at the top of the function. What we have added to this function is code that gets the second part of somebody’s email address, add “http://www.” to the beginning of this and are assuming that this will point to their email provider. Then we insert code into our function that will display this number beside an image of an envelope. I’ll leave it up to you to re-arrange things, for example we could have made the image of the envelope the background of the cell and then written the number of unread emails into that cell so that it would appear that the number is actually in front of the image, as the Messenger Client does.
&lt;p&gt;The second property from the User class that we want to take a look is the PendingContacts property. The Pending Contacts property gets the PendingContactCollection containing all of the user's pending contacts :-
&lt;p&gt; 
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1p5GsXy6QGspVIFJ1L8WKRDkl6lSPDLqvrG5t0iVYj5eKPZMf41s50Gczv-o7EGSFT5yCqj9uAuDc?PARTNER=WRITER"&gt;&lt;img title=MessPendingContactCollection style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=72 alt=MessPendingContactCollection src="http://byfiles.storage.msn.com/y1p8AQJ9JV9xKwzqhI3XUa2sxnpqnvriPpdzKaD-3mtTpMH3fhU32TySLBWQhq-rSqw_A3X2b5fhGQ?PARTNER=WRITER" width=160 border=0&gt;&lt;/a&gt; 
&lt;p&gt;This class exposes two properties as shown above :-
&lt;ul&gt;
&lt;li&gt;Count - gets the number of items in the collection 
&lt;li&gt;Item - gets the PendingContact at the specific index&lt;/ul&gt;
&lt;p&gt;This class is a collection class containing a list of Pending Contact objects. If we take a look at the PendingContact class we will see that there are two methods and two properties that are of interest. The properties are :-
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1p0XkgIL6Jz3PTmwEcommfl44FAvdKejPfboT43y_Q2MKgrX8RP2BChEzPjcSE2HA5G598-ethwxM?PARTNER=WRITER"&gt;&lt;img title=MessPendingContact style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=59 alt=MessPendingContact src="http://byfiles.storage.msn.com/y1pnjUIoP6z2MVUTrY1aQeoL2sg4s7ipGiyVZIBZGhpzADSlOvC9gxx5kQWT2JKfqysR40gUGctf0k?PARTNER=WRITER" width=173 border=0&gt;&lt;/a&gt; 
&lt;ul&gt;
&lt;li&gt;IMAddress - Gets the instant messaging address for the pending contact (requestor). 
&lt;li&gt;InviteMessage - Gets the text of the invitation message.&lt;/ul&gt;
&lt;p&gt;And the two methods of interest are :-
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pnjUIoP6z2MV9BvRGlgIWYJFNqZuePQESXpogdlkwQtpGIRJh7_5EM6GFgcOTkqDq33ILerj3D2g?PARTNER=WRITER"&gt;&lt;img title=MessPendingContactMethods style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=60 alt=MessPendingContactMethods src="http://byfiles.storage.msn.com/y1pMZePbMm66ICQeU7O9um-1vLnkvNGSRbvELSEd8qaDcq4U0zlMlYl3YcAF82DBAUB7lvkE2zvi_g?PARTNER=WRITER" width=127 border=0&gt;&lt;/a&gt; 
&lt;ul&gt;
&lt;li&gt;Accept - Accepts the pending contact and adds it to the user's contacts collection (which we will be going over in a later article). 
&lt;li&gt;Decline - Declines the pending contact and adds it to the user's blocked contacts list.&lt;/ul&gt;
&lt;p&gt;So first we want to display whether or not the user has any pending contacts. We will put this indicator directly below the number of unopened emails indicator on our control :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;a href='javascript:PendingContacts();'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;img src='WebMessenger/Images/PendingContact.gif' style='border: 0px;' /&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;span style='font-weight: bold; text-decoration: none;' id='PendingContacts'&amp;gt;&amp;amp;nbsp;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;result += PendingContacts;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;lt;/a&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;This simply calls a javascript function that will iterate through each pending contact and ask the user whether they want to accept the contact or deny them. If the user does not have any pending contacts then an alert will be displayed to tell them as much :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:green"&gt;//display list of pending contacts&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; PendingContacts()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; pendingCount = msgruser.get_pendingContacts().get_count();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;if&lt;/span&gt; (pendingCount &amp;gt; 0)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;for&lt;/span&gt; (&lt;span style="color:blue"&gt;var&lt;/span&gt; i = 0; i &amp;lt; pendingCount; i++)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;var&lt;/span&gt; pendingContact = msgruser.get_pendingContacts().get_item(i);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;var&lt;/span&gt; msg = pendingContact.get_imAddress().get_address();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            msg += &lt;span style="color:#a31515"&gt;&amp;quot; wants to be your contact&amp;lt;br&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            msg += pendingContact.get_inviteMessage();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            msg += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;br&amp;gt;Do you accept?&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;var&lt;/span&gt; res = confirm(msg);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;if&lt;/span&gt; (res == &lt;span style="color:blue"&gt;true&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                pendingContact.accept();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                pendingContact.decline();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:green"&gt;//Now reset the pending Contact count to 0&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;var&lt;/span&gt; pendContacts = $get(&lt;span style="color:#a31515"&gt;&amp;quot;PendingContacts&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        pendContacts.innerHTML = &lt;span style="color:#a31515"&gt;&amp;quot;0&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        alert(&lt;span style="color:#a31515"&gt;&amp;quot;You have no pending contacts&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;When you run the code now you have two indicators off to the right of the user information area, one for unread emails and the second for pending contacts :-
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pmRlpoG_zjMImSHtRl6M6nreE8I3219oOpueuHQsfWKOCGJnD7a5uLN-fCcwDZAXcMT6xQnnCmMo?PARTNER=WRITER"&gt;&lt;img title=MessControl style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=78 alt=MessControl src="http://byfiles.storage.msn.com/y1p96iUcgG3WyiyiwzySB0-ffYbAkmUbaOaluG1tMAQpplwaUC4jpsxALST4liXNB8s3zjHOxdjAwo?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-2719028481651278955&amp;page=RSS%3a+Creating+a+Web+Messenger+control+from+Scratch+%e2%80%93+Part+6&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=msnwindowslive.spaces.live.com&amp;amp;GT1=MSNWindowsLive"&gt;</description><category>Programming</category><comments>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!783.entry#comment</comments><guid isPermaLink="true">http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!783.entry</guid><pubDate>Mon, 06 Oct 2008 21:16:29 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://MSNWindowsLive.spaces.live.com/blog/cns!DA44120081017B95!783/comments/feed.rss</wfw:commentRss><wfw:comment>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!783.entry#comment</wfw:comment><dcterms:modified>2008-10-06T21:16:29Z</dcterms:modified></item><item><title>Creating a Web Messenger control from Scratch – Part 5</title><link>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!760.entry</link><description>&lt;p&gt;In the last part of this series we covered customizing the Windows Live Sign-In Control and some of the new features that have been added to the API for this control.  In this part we will cover some of the new features that are available for Users’ Contacts and the User him/herself.  &lt;p&gt;So now that you are able to sign-in to your messenger User Control, we want to display some information about who’s actually signed in. &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pr-LV35JWHy6cUGVlC9XU9H8ryHSvdI_xyu6kIeTzZQeA0n6FYqXWsTVEARNhHhiS?PARTNER=WRITER"&gt;&lt;img title=MessClientUser style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px" height=71 alt=MessClientUser src="http://byfiles.storage.msn.com/y1pbuFTNqjhdwKJtkQGTDAKh0wj9O5bqxGi9hS7y8x3cTXj8puPSPnqqMnObrY4gf911L2jmtbr4x4?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;p&gt;This is what the actual Messenger Wave 3 Beta Client looks like when a user has signed in. We would preferably  like our Messenger User Control to look similar.  The main elements to this are the users display picture, the user’s name and a personal message if the user has set one. &lt;p&gt;So how do we do this. All the functionality to do with the currently signed in user can be found in the User class :- &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1psLwVvEvgIqikCskyig2lBI9RkVsm42V1DuctmrbQyho_Kh8qv09ybtQaTZ5J5lS0KdS9SxRCh7o?PARTNER=WRITER"&gt;&lt;img title=MessUserClass style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px" height=354 alt=MessUserClass src="http://byfiles.storage.msn.com/y1p_1D_hzUf539MsmX-Fplcizp-dpQ5yY0VNBERG4nrkOHFM2QVKL4U_l7vU48Bw4zaTKmBcEJd5og?PARTNER=WRITER" width=87 border=0&gt;&lt;/a&gt;  &lt;p&gt;We don’t need all these properties at the moment and some we will go over in a later article in this series. The ones we’re interested in at the moment are :- &lt;ul&gt; &lt;li&gt;Address - Gets the IMAddress for the user. &lt;li&gt;Presence - Gets the IMAddressPresence for the user. &lt;/ul&gt; &lt;p&gt;Between these two properties we can get all the information we are looking for. So first off lets take a look at the properties for the IMAddress class :- &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pkkmIz-J4JA80ezVdAx_I70hl6L4k6iuEaJ-RJf51ouH0c_x8X1KjksUOhJhbSFVWyHVPAhr-0Fs?PARTNER=WRITER"&gt;&lt;img title=MessAddressClass style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px" height=244 alt=MessAddressClass src="http://byfiles.storage.msn.com/y1pkkmIz-J4JA8zxqd36C15R0CQY-LpRM5Rc4ak8pTnXGZDBQfgpiY5X5IydA9TkXNXWBgXKGb5qRw?PARTNER=WRITER" width=153 border=0&gt;&lt;/a&gt;  &lt;p&gt;Although again there are various properties that we can query, we are really only interested in one at the moment which is the actual User’s Address :- &lt;ul&gt; &lt;li&gt;Address - Gets a string containing the address for the IMAddress. &lt;/ul&gt; &lt;p&gt;This is the user’s actual email address. Why do we need this?  When we are displaying the user’s information remember that we want to display the user’s name and also their personal message. Both of these are optional. Therefore if we get the user’s name and it’s blank we want to have something to display. In this case we will display the user’s E-Mail address instead. &lt;p&gt;As with most things in the Messenger API, there are multiple ways that we could do this, for example we could create a variable that would hold the instantiated class information for the IMAddress class then get the information from this.  The method that we will use will be to simply chain the calls together.  &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userAddress = msgruser.get_address().get_address();&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Here we get the IMAddress instance from our user class then call the get_address() property from the instantiated IMAddress class. This will return a string containing the user’s email address into our userAddress variable.
&lt;p&gt;As you can see from the Properties listed above, we could get the user’s presence from the IMAddress class however we will get the user’s presence directly from the user class :-
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pMoASCcFy3iz5UxjOKF_V3STi25EC7YxGfHtUoQTdgjPQHgGcQeZZG2GCY9DW8HO4GImVktuuMfQ?PARTNER=WRITER"&gt;&lt;img title=MessPresenceClass style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px" height=166 alt=MessPresenceClass src="http://byfiles.storage.msn.com/y1ps5D757xtUcn41nDKjqva47S480bS89WWkMZ64zqbhVhVweclCjB8AxUyT0rxsg9f3CTsvm395Jw?PARTNER=WRITER" width=190 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Above are the properties of the IMAddressPresence class.
&lt;ul&gt;
&lt;li&gt;DisplayName - Gets or sets the display name string for the instant messaging address. 
&lt;li&gt;DisplayPictureUrl - Gets the display picture URL for the instant messaging address.
&lt;li&gt;IMAddress - Gets the associated instant messaging address (IMAddress). 
&lt;li&gt;PersonalMessage - Gets or sets the personal message for the instant messaging address. 
&lt;li&gt;Properties - Gets the properties associated with the address. 
&lt;li&gt;Status - Gets or sets the status for the instant messaging address. &lt;/ul&gt;
&lt;p&gt;From this we want the user’s display name, their personal message and also their display picture. We also want their status (which indicates if they are currently online, away etc. :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userDispName = msgruser.get_presence().get_displayName();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userPersonalMessage = msgruser.get_presence().get_personalMessage();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userPicture = msgruser.get_presence().get_displayPictureUrl();&lt;/pre&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userStatus = Enum.toString(Microsoft.Live.Messenger.PresenceStatus, msgruser.get_presence().get_status());&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;/div&gt;
&lt;p&gt;As you can see from the above code, Status actually returns an instance of PresenceStatus which is an enumeration giving us the following options :-
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pLVqDqa-Sp420b8V-oVmZUoRKJwvsdOKckZkNHtzjdWKpvJ8tK_ad5O8cTDWtt-nGPYqELNtG9dU?PARTNER=WRITER"&gt;&lt;img title=MessPresenceStatus style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px" height=189 alt=MessPresenceStatus src="http://byfiles.storage.msn.com/y1pYL5S0pCr-sl7I_v4Q-Uu-mv3nX47o2bmO-mi6ZveAyV0U8IrlRdAh-QsdohQe1BJfTXc-jKcnc4?PARTNER=WRITER" width=440 border=0&gt;&lt;/a&gt; 
&lt;p&gt;We will also use the Status to show the halo effect surrounding the user’s image as does the new Live Messenger Wave 3 beta client.
&lt;p&gt;The next thing that we have to do is to check whether a valid image has been returned for the call to get_displayPictureUrl(). Sometimes a user will not have a display image in which case the call should return null. Sometimes the display picture may be a downloaded animated image used by the Messenger client (as mine is). In this case, it’s not actually a valid image that can be displayed. In either of these cases we want to display a default image. Otherwise we will use the image supplied :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userPicLast3 = userPicture.substr(userPicture.length - 3);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; pic = &lt;span style="color:blue"&gt;new&lt;/span&gt; Image();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt; (userPicLast3 !== &lt;span style="color:#a31515"&gt;&amp;quot;jpg&amp;quot;&lt;/span&gt; &amp;amp;&amp;amp; userPicLast3 !== &lt;span style="color:#a31515"&gt;&amp;quot;gif&amp;quot;&lt;/span&gt; &amp;amp;&amp;amp; userPicLast3 !== &lt;span style="color:#a31515"&gt;&amp;quot;png&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    pic.src = &lt;span style="color:#a31515"&gt;&amp;quot;WebMessenger/Images/MsgrNoImage.gif&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{    &lt;/pre&gt;&lt;pre style="margin:0px"&gt;    pic.src = userPicture;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    pic.onerror = &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        pic.src = &lt;span style="color:#a31515"&gt;&amp;quot;WebMessenger/Images/MsgrNoImage.gif&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;One anomaly that I have found is that the returned value from the get_displayPictureUrl() property is actually an object and not just a string. However within the object is a variable $0 which actually holds the url. Therefore we need to extract this value before we execute the above code. This is done simply by :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;userPicture = userPicture.$0;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;So now we have either the user’s display picture or a default image to display. Next we want to create a string that concatenates the users display name, email address and status or if the user does not have a display name, just their email address and status :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userName = &lt;span style="color:blue"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt; (userDispName !== &lt;span style="color:#a31515"&gt;''&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    userName = userDispName + &lt;span style="color:#a31515"&gt;' ('&lt;/span&gt; + userAddress + &lt;span style="color:#a31515"&gt;'): '&lt;/span&gt; + userStatus;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    userName = userAddress + &lt;span style="color:#a31515"&gt;': '&lt;/span&gt; + userStatus;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Finally we want to display this information.  I’ve formatted the information into a table and simply insert that table into the Div as innerHTML once it has been constructed :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; userDisplay = getSignInCode(pic.src, userName, userPersonalMessage, userStatus);&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;The getSignInCode function simply creates the raw html to be inserted in the Div element :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; getSignInCode(picUrl, userName, userMessage, userStatus)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; result = &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;table width='100%'&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td rowspan='2' width='42px' style='padding: 2px; background-color: &amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;if&lt;/span&gt; (userStatus.toLowerCase() == &lt;span style="color:#a31515"&gt;&amp;quot;online&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#00cc00;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt; &lt;span style="color:blue"&gt;if&lt;/span&gt; (userStatus.toLowerCase() == &lt;span style="color:#a31515"&gt;&amp;quot;offline&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#cc0000;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        result += &lt;span style="color:#a31515"&gt;&amp;quot;#E3AC4F;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;'&amp;gt;&amp;lt;img width='40px' src='&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += picUrl;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;'&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td align='center'&amp;gt;&amp;lt;span style='font-weight: bold; font-family: Tahoma,arial,sans-serif; font-size:12px;'&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += userName;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += userMessage;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    result += &lt;span style="color:#a31515"&gt;&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;return&lt;/span&gt; result;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Here we pass in the url of the image, the users name (concatenated string from above), their display message and also their status. The status as you can see if used to color the background and emulate the halo effect around the users picture giving an at-a-glance indication of the users status.
&lt;p&gt;Once we have this code, we first clear anything that we had in the user information Div then we simply insert it into the Div element we had on our page for user information and finally we also update insert the user’s personal message into a textbox should they want to change it at somepoint. We will cover this at a later date :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;removeChildrenFromNode(&lt;span style="color:#a31515"&gt;'userInfo'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;userInfo.innerHTML = userDisplay;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;document.getElementById(&lt;span style="color:#a31515"&gt;'personalMessage'&lt;/span&gt;).value = userPersonalMessage;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;The removeChildrenFromNode function is below :-
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:green"&gt;/* Clear all children from the specified node &lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:green"&gt;(i.e. clear messages from the conversation window). */&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; removeChildrenFromNode(id)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; node = document.getElementById(id);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;if&lt;/span&gt; (node == undefined || node == &lt;span style="color:blue"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;return&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;var&lt;/span&gt; len = node.childNodes.length;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;while&lt;/span&gt; (node.hasChildNodes())&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        node.removeChild(node.firstChild);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;The only thing left to do now is to place the call to our displayUserInfo() function in the signInCompleted handler we setup previously and you should see something like the following when you run it :-
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pLPvRClgRNmfEsYhcIfAjKFWCUHRJIrbnm0jC7rjiGueK71TAm9PwmAhqGUYteO1QYUhZrd9LeP8?PARTNER=WRITER"&gt;&lt;img title=MessSignedIn style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px" height=81 alt=MessSignedIn src="http://byfiles.storage.msn.com/y1puR_L1TqqTyxeLDjcD-Uay_w1RaSqwv_cmNxecmHwaCxH2nusJYRNtHdp7xTxHb_n0fWOcqCybpo?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt; 
&lt;p&gt;Due to my animated graphic I am just displaying a default image. Notice the green background around the image identifying that I am currently online.
&lt;p&gt;More to come shortly….
&lt;div style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Windows+Live" rel=tag&gt;Windows Live&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Messenger" rel=tag&gt;Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Web+Messenger" rel=tag&gt;Web Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/API" rel=tag&gt;API&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Programming" rel=tag&gt;Programming&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Windows+Live+Web+Messenger" rel=tag&gt;Windows Live Web Messenger&lt;/a&gt;&lt;/div&gt;&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-2719028481651278955&amp;page=RSS%3a+Creating+a+Web+Messenger+control+from+Scratch+%e2%80%93+Part+5&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=msnwindowslive.spaces.live.com&amp;amp;GT1=MSNWindowsLive"&gt;</description><category>Programming</category><comments>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!760.entry#comment</comments><guid isPermaLink="true">http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!760.entry</guid><pubDate>Thu, 02 Oct 2008 20:36:02 GMT</pubDate><slash:comments>1</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://MSNWindowsLive.spaces.live.com/blog/cns!DA44120081017B95!760/comments/feed.rss</wfw:commentRss><wfw:comment>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!760.entry#comment</wfw:comment><dcterms:modified>2008-10-02T20:36:02Z</dcterms:modified></item><item><title>Creating a Web Messenger control from Scratch – Part 4</title><link>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!724.entry</link><description>&lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Windows+Live" rel=tag&gt;Windows Live&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Messenger" rel=tag&gt;Messenger&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Windows+Live+Web+Messenger" rel=tag&gt;Windows Live Web Messenger&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Web+Messenger" rel=tag&gt;Web Messenger&lt;/a&gt;,&lt;a href="http://technorati.com/tags/How+To" rel=tag&gt;How To&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Progamming" rel=tag&gt;Progamming&lt;/a&gt;,&lt;a href="http://technorati.com/tags/API" rel=tag&gt;API&lt;/a&gt;&lt;/div&gt; &lt;p&gt;In the last part of this tutorial we covered the links and the new Show and Hide functionality of the Sign-In control. In this part, as promised, we will get to the customization options that are available to you with the Sign-In control. &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pxR9nopXPhgH7Z5wlLETfSTVq3BtQoTRTRUPLi0KBckRuDv3f1uLcNBnOG9Ex-_88?PARTNER=WRITER"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" title=SignInAPI border=0 alt=SignInAPI src="http://byfiles.storage.msn.com/y1pOoRysiI1OZX9Y5h4snkc5PStBLcIbrI7ojXb-eTLkBH_AOE1OyM5wRrNNvf3FR-mc3Z-YW2nnKw?PARTNER=WRITER" width=196 height=112&gt;&lt;/a&gt;  &lt;p&gt;Taking a quick look at the Sign-In control API we see that there is a Style property. As with the links property covered in an earlier article, this is a getter that returns a class of type SignInControlStyle. So once you have got a reference to this class what does it offer you? &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1p9tmL-1nIP3afQX-9g04Tib4st9d9lPP2J_-5PPKpccWo_jxEv7f5vjYcaK83O1bn_5MtHMXibIE?PARTNER=WRITER"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" title=StyleAPI border=0 alt=StyleAPI src="http://byfiles.storage.msn.com/y1pPY5hsePNj_cYaAdNcxMPOh_vTbj-FF-VNmbj0Td-O6HH7lPuEEjSTfJteBKA146b-Snnm0Zt4gs?PARTNER=WRITER" width=244 height=200&gt;&lt;/a&gt;  &lt;p&gt;Taking a look at the API you’ll see that it exposes seven properties that allow you to change various aspects of the Sign-In control :- &lt;ul&gt; &lt;li&gt;Background gets or sets the background color property for the SignInControl  &lt;li&gt;BorderColor gets or sets the border color property for the SignInControl  &lt;li&gt;ButtonBackColor gets or sets the button background color property for the SignInControl  &lt;li&gt;ButtonBorderColor gets or sets the button border color property for the SignInControl  &lt;li&gt;ButtonForeColor gets or sets the button foreground color property for the SignInControl  &lt;li&gt;ForeColor gets or sets the foreground color property for the SignInControl  &lt;li&gt;LinkColor gets or sets the link color property for the SignInControl&lt;/ul&gt; &lt;p&gt;If we take a look at the SignInControlStyle code you will see the following :- &lt;div style="font-family:courier new;background:white;color:black;font-size:10pt"&gt;&lt;pre style="margin:0px"&gt;Microsoft.Live.Messenger.UI.SignInControlStyle.prototype={&lt;/pre&gt;&lt;pre style="margin:0px"&gt;$0:&lt;span style="color:blue"&gt;null&lt;/span&gt;,$1:&lt;span style="color:blue"&gt;null&lt;/span&gt;,add_$2:&lt;span style="color:blue"&gt;function&lt;/span&gt;($p0){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$3=Delegate.combine(&lt;span style="color:blue"&gt;this&lt;/span&gt;.$3,$p0);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;remove_$2:&lt;span style="color:blue"&gt;function&lt;/span&gt;($p0){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$3=Delegate.remove(&lt;span style="color:blue"&gt;this&lt;/span&gt;.$3,$p0);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;$3:&lt;span style="color:blue"&gt;null&lt;/span&gt;,get_$4:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.$0;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;get_backColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.backColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;set_backColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(value){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.backColor=&lt;span style="color:blue"&gt;this&lt;/span&gt;.$5(value);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$6();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;get_foreColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.foreColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;set_foreColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(value){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.foreColor=&lt;span style="color:blue"&gt;this&lt;/span&gt;.$5(value);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$6();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;get_borderColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.borderColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;set_borderColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(value){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.borderColor=&lt;span style="color:blue"&gt;this&lt;/span&gt;.$5(value);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$6();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;get_linkColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.linkColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;set_linkColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(value){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.linkColor=&lt;span style="color:blue"&gt;this&lt;/span&gt;.$5(value);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$6();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;get_buttonForeColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.buttonForeColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;set_buttonForeColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(value){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.buttonForeColor=&lt;span style="color:blue"&gt;this&lt;/span&gt;.$5(value);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$6();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;get_buttonBackColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.buttonBackColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;set_buttonBackColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(value){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.buttonBackColor=&lt;span style="color:blue"&gt;this&lt;/span&gt;.$5(value);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$6();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;get_buttonBorderColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.buttonBorderColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;set_buttonBorderColor:&lt;span style="color:blue"&gt;function&lt;/span&gt;(value){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$0.buttonBorderColor=&lt;span style="color:blue"&gt;this&lt;/span&gt;.$5(value);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$6();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;$5:&lt;span style="color:blue"&gt;function&lt;/span&gt;($p0){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt;(String.isNullOrEmpty($p0))&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;throw&lt;/span&gt; Microsoft.Live.Messenger._M$8.$1(&lt;span style="color:#a31515"&gt;'color'&lt;/span&gt;,$p0);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;var&lt;/span&gt; $0=&lt;span style="color:blue"&gt;new&lt;/span&gt; RegExp(&lt;span style="color:#a31515"&gt;'^#[0-9a-f]{6,6}$'&lt;/span&gt;,&lt;span style="color:#a31515"&gt;'i'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt;(!$0.test($p0))&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;throw&lt;/span&gt; Microsoft.Live.Messenger._M$8.$5(&lt;span style="color:#a31515"&gt;'color'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;return&lt;/span&gt; Microsoft.Live.Messenger._M$7.$1($p0);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;$6:&lt;span style="color:blue"&gt;function&lt;/span&gt;(){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt;(!&lt;span style="color:blue"&gt;this&lt;/span&gt;.$1)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$1=&lt;span style="color:blue"&gt;new&lt;/span&gt; Microsoft.Live.Messenger._M$A(Delegate.create(&lt;span style="color:blue"&gt;this&lt;/span&gt;,&lt;span style="color:blue"&gt;this&lt;/span&gt;.$7),&lt;span style="color:blue"&gt;null&lt;/span&gt;,1,Microsoft.Live.Messenger._M$5.$0);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;},&lt;/pre&gt;&lt;pre style="margin:0px"&gt;$7:&lt;span style="color:blue"&gt;function&lt;/span&gt;($p0){&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$1.dispose();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$1=&lt;span style="color:blue"&gt;null&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt;(&lt;span style="color:blue"&gt;this&lt;/span&gt;.$3)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;this&lt;/span&gt;.$3.invoke(&lt;span style="color:blue"&gt;this&lt;/span&gt;,EventArgs.Empty);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;From this code you’ll notice that any input value that you provide to a setter for a color gets assigned to $5. If you don’t provide an input value to a setter then an exception will be thrown, otherwise the value that you supply will be checked against a regular expression - RegExp(&lt;span style="color:#a31515"&gt;'^#[0-9a-f]{6,6}$'&lt;/span&gt;,&lt;span style="color:#a31515"&gt;'i'&lt;/span&gt;). This expression basically says that must supply a color in the format &amp;quot;#RRGGBB&amp;quot;, with values between 0-F hex. If you don’t then an exception will be thrown, otherwise your value will be assigned to the appropriate variable that you called. One thing I would have liked to see is the ability to have a background image for the Sign-In control rather than just be able to assign colors. 
&lt;p&gt;Back to our code. You’ve now seen which properties are available to you and how Microsoft have implemented the SignInControlStyle class. Lets use it. Obviously you can’t use this class until you have an instance of the Sign-In control, so lets create a function that gets called immediately after the Sign-In control has been instantiated :-
&lt;div style="font-family:courier new;background:white;color:black;font-size:10pt"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; startMessenger(backColor, linkColor)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;   &lt;span style="color:blue"&gt;var&lt;/span&gt; privacyUrl = &lt;span style="color:#a31515"&gt;'http://localhost:44444/WLWebMessenger/WebMessenger/Privacy.htm'&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;   &lt;span style="color:blue"&gt;var&lt;/span&gt; channelUrl = &lt;span style="color:#a31515"&gt;'http://localhost:44444/WLWebMessenger/WebMessenger/Channel.htm'&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;   signincontrol = &lt;span style="color:blue"&gt;new&lt;/span&gt; Microsoft.Live.Messenger.UI.SignInControl(&lt;span style="color:#a31515"&gt;'signinframe'&lt;/span&gt;, privacyUrl, channelUrl, &lt;span style="color:#a31515"&gt;'en-US'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;   changeSignInStyle(backColor, linkColor);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;   signincontrol.add_authenticationCompleted(Delegate.create(&lt;span style="color:blue"&gt;null&lt;/span&gt;, authenticationCompleted));&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;In our function we are going to set the background color and the link colors so that they match (as close as I can get them) to our User Controls color, so we pass in the background color and link colors to our startup routine. 
&lt;p&gt;As we have added some code to allow the user to customize the color of our User Control, we need to add some code so that the  colors we pass into our changeSignInStyle routine match whichever color the user selects as their background color scheme. If you have been following this series so far you will remember that our colors are stored in a custom class we defined. Therefore that’s where we will add some code to store the background and link colors for our Sign-In control :-
&lt;div style="font-family:courier new;background:white;color:black;font-size:10pt"&gt;&lt;pre style="margin:0px"&gt;Type.registerNamespace(&lt;span style="color:#a31515"&gt;&amp;quot;Messenger&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt; &lt;/pre&gt;&lt;pre style="margin:0px"&gt;Messenger.UI = &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;this&lt;/span&gt;.BackgroundColor = &lt;span style="color:#a31515"&gt;&amp;quot;blue&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;this&lt;/span&gt;.SignInBackColor = &lt;span style="color:#a31515"&gt;&amp;quot;#ffffff&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;this&lt;/span&gt;.SignInLinkColor = &lt;span style="color:#a31515"&gt;&amp;quot;#0066A7&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;this&lt;/span&gt;.PassportImage = &lt;span style="color:#a31515"&gt;&amp;quot;WebMessenger/Images/Passport.gif&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt; &lt;/pre&gt;&lt;pre style="margin:0px"&gt;Messenger.UI.prototype =&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            get_BackgroundColor: &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.BackgroundColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            set_BackgroundColor: &lt;span style="color:blue"&gt;function&lt;/span&gt;(value)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;this&lt;/span&gt;.BackgroundColor = value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;this&lt;/span&gt;.SetBackgroundColor();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            get_SignInBackColor: &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.SignInBackColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            set_SignInBackColor: &lt;span style="color:blue"&gt;function&lt;/span&gt;(value)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;this&lt;/span&gt;.SignInBackColor = value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            get_SignInLinkColor: &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.SignInLinkColor;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            set_SignInLinkColor: &lt;span style="color:blue"&gt;function&lt;/span&gt;(value)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;this&lt;/span&gt;.SignInLinkColor = value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            get_PassportImage: &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;return&lt;/span&gt; &lt;span style="color:blue"&gt;this&lt;/span&gt;.PassportImage;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            set_PassportImage: &lt;span style="color:blue"&gt;function&lt;/span&gt;(value)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;this&lt;/span&gt;.PassportImage = value;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            SetBackgroundColor: &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;var&lt;/span&gt; msgr = document.getElementById(&lt;span style="color:#a31515"&gt;&amp;quot;webmsgr&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;var&lt;/span&gt; background = &lt;span style="color:#a31515"&gt;&amp;quot;url(WebMessenger/Images/background_small_&amp;quot;&lt;/span&gt; + &lt;span style="color:blue"&gt;this&lt;/span&gt;.get_BackgroundColor() + &lt;span style="color:#a31515"&gt;&amp;quot;.gif)&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;var&lt;/span&gt; passImage = &lt;span style="color:#a31515"&gt;&amp;quot;WebMessenger/Images/Passport&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;var&lt;/span&gt; PassPortImage = $get(&lt;span style="color:#a31515"&gt;&amp;quot;PassportImage&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:green"&gt;//alert(background);&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                msgr.style.backgroundImage = background;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                &lt;span style="color:blue"&gt;switch&lt;/span&gt; (&lt;span style="color:blue"&gt;this&lt;/span&gt;.get_BackgroundColor())&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                    &lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;blue&amp;quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInBackColor(&lt;span style="color:#a31515"&gt;&amp;quot;#6196BC&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInLinkColor(&lt;span style="color:#a31515"&gt;&amp;quot;#FFFFFF&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_PassportImage(passImage + &lt;span style="color:#a31515"&gt;&amp;quot;Blue.gif&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                    &lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;green&amp;quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInBackColor(&lt;span style="color:#a31515"&gt;&amp;quot;#ACFFAA&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInLinkColor(&lt;span style="color:#a31515"&gt;&amp;quot;#0066A7&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_PassportImage(passImage + &lt;span style="color:#a31515"&gt;&amp;quot;Green.gif&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                    &lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;red&amp;quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInBackColor(&lt;span style="color:#a31515"&gt;&amp;quot;#FF2727&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInLinkColor(&lt;span style="color:#a31515"&gt;&amp;quot;#0066A7&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_PassportImage(passImage + &lt;span style="color:#a31515"&gt;&amp;quot;Red.gif&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                    &lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;cyan&amp;quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInBackColor(&lt;span style="color:#a31515"&gt;&amp;quot;#55EFFF&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInLinkColor(&lt;span style="color:#a31515"&gt;&amp;quot;#FFFFFF&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_PassportImage(passImage + &lt;span style="color:#a31515"&gt;&amp;quot;Cyan.gif&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                    &lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;yellow&amp;quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInLinkColor(&lt;span style="color:#a31515"&gt;&amp;quot;#0066A7&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInBackColor(&lt;span style="color:#a31515"&gt;&amp;quot;#FFF84C&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_PassportImage(passImage + &lt;span style="color:#a31515"&gt;&amp;quot;Yellow.gif&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                    &lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;purple&amp;quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInLinkColor(&lt;span style="color:#a31515"&gt;&amp;quot;#0066A7&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInBackColor(&lt;span style="color:#a31515"&gt;&amp;quot;#FF4CF5&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_PassportImage(passImage + &lt;span style="color:#a31515"&gt;&amp;quot;Purple.gif&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                    &lt;span style="color:blue"&gt;case&lt;/span&gt; &lt;span style="color:#a31515"&gt;&amp;quot;grey&amp;quot;&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInBackColor(&lt;span style="color:#a31515"&gt;&amp;quot;#AAAAAA&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInLinkColor(&lt;span style="color:#a31515"&gt;&amp;quot;#0066A7&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_PassportImage(passImage + &lt;span style="color:#a31515"&gt;&amp;quot;Grey.gif&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                    &lt;span style="color:blue"&gt;default&lt;/span&gt;:&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:green"&gt;//Set default color to blue;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_SignInBackColor(&lt;span style="color:#a31515"&gt;&amp;quot;#4182B1&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                        &lt;span style="color:blue"&gt;this&lt;/span&gt;.set_PassportImage(passImage + &lt;span style="color:#a31515"&gt;&amp;quot;.gif&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;                PassPortImage.src = &lt;span style="color:blue"&gt;this&lt;/span&gt;.get_PassportImage();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            },&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            dispose: &lt;span style="color:blue"&gt;function&lt;/span&gt;()&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            { }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;Messenger.UI.registerClass(&lt;span style="color:#a31515"&gt;&amp;quot;Messenger.UI&amp;quot;&lt;/span&gt;, &lt;span style="color:blue"&gt;null&lt;/span&gt;, Sys.IDisposable);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt; (&lt;span style="color:blue"&gt;typeof&lt;/span&gt; (Sys) !== &lt;span style="color:#a31515"&gt;&amp;quot;undefined&amp;quot;&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    Sys.Application.notifyScriptLoaded();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;We add a couple of variables to the routine to store the background and link colors, provide some getters and setters turning them in properties and then in the main routine we assign appropriate colors based on which color scheme the user has chosen.
&lt;div style="font-family:courier new;background:white;color:black;font-size:10pt"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:green"&gt;//Add some startup script&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;if&lt;/span&gt; (!Page.ClientScript.IsStartupScriptRegistered(&lt;span style="color:blue"&gt;this&lt;/span&gt;.GetType(), &lt;span style="color:#a31515"&gt;&amp;quot;Load&amp;quot;&lt;/span&gt;))&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;string&lt;/span&gt; str = &lt;span style="color:#a31515"&gt;&amp;quot;var msgrui; function pageLoad(sender, args)&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            str += &lt;span style="color:#a31515"&gt;&amp;quot;{msgrui = new Messenger.UI(); startMessenger(msgrui.get_SignInBackColor(), msgrui.get_SignInLinkColor());}&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:#2b91af"&gt;ScriptManager&lt;/span&gt;.RegisterStartupScript(&lt;span style="color:blue"&gt;this&lt;/span&gt;.Page, &lt;span style="color:blue"&gt;this&lt;/span&gt;.GetType(), &lt;span style="color:#a31515"&gt;&amp;quot;Load&amp;quot;&lt;/span&gt;, str, &lt;span style="color:blue"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;In our User Control code behind page we need to amend the startup script so that we now pass in the values of our intended background and link colors.
&lt;div style="font-family:courier new;background:white;color:black;font-size:10pt"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;div&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;setAppearance&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;span&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;Change Your Appearance:&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;span&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;div&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;colorPicker&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;javascript:msgrui.set_BackgroundColor('blue');changeSignInStyle(msgrui.get_SignInBackColor(), msgrui.get_SignInLinkColor());&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/picker_small_blue.gif&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;javascript:msgrui.set_BackgroundColor('cyan');changeSignInStyle(msgrui.get_SignInBackColor(), msgrui.get_SignInLinkColor());&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/picker_small_cyan.gif&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;javascript:msgrui.set_BackgroundColor('purple');changeSignInStyle(msgrui.get_SignInBackColor(), msgrui.get_SignInLinkColor());&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/picker_small_purple.gif&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;javascript:msgrui.set_BackgroundColor('red');changeSignInStyle(msgrui.get_SignInBackColor(), msgrui.get_SignInLinkColor());&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/picker_small_red.gif&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;javascript:msgrui.set_BackgroundColor('green');changeSignInStyle(msgrui.get_SignInBackColor(), msgrui.get_SignInLinkColor());&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/picker_small_green.gif&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;javascript:msgrui.set_BackgroundColor('yellow');changeSignInStyle(msgrui.get_SignInBackColor(), msgrui.get_SignInLinkColor());&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/picker_small_yellow.gif&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;javascript:msgrui.set_BackgroundColor('grey');changeSignInStyle(msgrui.get_SignInBackColor(), msgrui.get_SignInLinkColor());&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/picker_small_grey.gif&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;div&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;div&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Also in our User Control itself we need to alter the section where we allow the user to select which color scheme they want and place a call directly into our changeSignInStyle function.
&lt;div style="font-family:courier new;background:white;color:black;font-size:10pt"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; changeSignInStyle(backColor, linkColor) &lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;  &lt;span style="color:green"&gt;//Obtain an instance of the SignInControlStyle class&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    signinstyle = &lt;span style="color:blue"&gt;new&lt;/span&gt; Microsoft.Live.Messenger.UI.SignInControlStyle();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    signinstyle = signincontrol.get_style();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:green"&gt;//Set the controls background color and link color&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    signinstyle.set_backColor(backColor);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    signinstyle.set_linkColor(linkColor);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Finally in our MessengerFns Javascript code we put the changeSignInStyle routine. Here we are instantiating the SignInControlStyle class, calling the get_style() property of the Sign-In control then assigning the background color and link color passed in with our code above to the appropriate properties of the SignInControlStyle class. Now whenever the user chooses a new color scheme, our Sign-In control changes color to match rather than staying the default white :-
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pBPRPV3MxjzHKygh-3uaytwFof9mD_9JOTKKutl8vCWXIMFSOrky9S4gAZgJJyQg5u97YWlA6f40?PARTNER=WRITER"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" title=MessCyan border=0 alt=MessCyan src="http://byfiles.storage.msn.com/y1pQft9SS1sgLU4ykVrNjH6jauko3iPtocK36tY7CKko79HYLH2FBErx2S0i0j4sc7SHAUcPJAGoOo?PARTNER=WRITER" width=244 height=148&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1p5sH5nWHO13IcE9vsTk0k0TdXCQkCyiPQmHHzC57FNzki5CzjHW5-AHmIu9lAJk_ZEwG3YdQ1UAg?PARTNER=WRITER"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" title=MessBlue border=0 alt=MessBlue src="http://byfiles.storage.msn.com/y1pHgQKETc5FuFIB8RM8tTtWvkoXg3UrtoQJ3L1riH7za6lol25OaqcHskc_YLQPaajQXJ4TYLjqyI?PARTNER=WRITER" width=244 height=149&gt;&lt;/a&gt; 
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pnoKtvqHZYYrVeE2Xo-d8E9idLxsOHbQDnSa3Otpmu2BrKEY4PScz8hEdX1dF-iIQeAuHFLzRBsY?PARTNER=WRITER"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" title=MessPurple border=0 alt=MessPurple src="http://byfiles.storage.msn.com/y1pezBSsIh5tDAP0roRNo30n7-R_ILJ14Nh2g-Qy5-hVeae7HWHw_qWESXEmi0P4k0q-uTskk9idTA?PARTNER=WRITER" width=244 height=147&gt;&lt;/a&gt; 
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pKtqQ4z5OYe3pzUsnGE-cyVuAQivxbKhDAtZ_yXPg87Yh1ozL6Kp1X8dX7CUObZkDkxHr6zie6x4?PARTNER=WRITER"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px" title=MessYellow border=0 alt=MessYellow src="http://byfiles.storage.msn.com/y1pNGDITFD4JRG1fr3tSfM8WvPT-TmVSGzjwdzO-cQGZBlLmAn2VaGjMfjFo3UyAeZVUOFSDR0ObDA?PARTNER=WRITER" width=244 height=150&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;p&gt;Our messenger User Control is starting to come together style wise. In the next part we will take a look at what else you can do once a user has signed in.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=-2719028481651278955&amp;page=RSS%3a+Creating+a+Web+Messenger+control+from+Scratch+%e2%80%93+Part+4&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=msnwindowslive.spaces.live.com&amp;amp;GT1=MSNWindowsLive"&gt;</description><category>Programming</category><comments>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!724.entry#comment</comments><guid isPermaLink="true">http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!724.entry</guid><pubDate>Sat, 27 Sep 2008 16:41:41 GMT</pubDate><slash:comments>2</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://MSNWindowsLive.spaces.live.com/blog/cns!DA44120081017B95!724/comments/feed.rss</wfw:commentRss><wfw:comment>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!724.entry#comment</wfw:comment><dcterms:modified>2008-09-27T16:41:41Z</dcterms:modified></item><item><title>Creating a Web Messenger control from Scratch – Part 3</title><link>http://MSNWindowsLive.spaces.live.com/Blog/cns!DA44120081017B95!701.entry</link><description>&lt;div style="padding-right:0px;display:inline;padding-left:0px;float:none;padding-bottom:0px;margin:0px;padding-top:0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Windows+Live" rel=tag&gt;Windows Live&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Windows+Live+Web+Messenger" rel=tag&gt;Windows Live Web Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Messenger" rel=tag&gt;Messenger&lt;/a&gt;, &lt;a href="http://technorati.com/tags/Programming" rel=tag&gt;Programming&lt;/a&gt;, &lt;a href="http://technorati.com/tags/How+To" rel=tag&gt;How To&lt;/a&gt;, &lt;a href="http://technorati.com/tags/User+Control" rel=tag&gt;User Control&lt;/a&gt;&lt;/div&gt; &lt;p&gt;In the last part of this series we added the necessary framework to put in the place the sign-in control and get it working. &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pHvri1j76YUd8HKcvssqox_-9RBbwhyFbPLRAoGf5aKGcIrzZDWj3gwh5-Yjcxp2M?PARTNER=WRITER"&gt;&lt;img title=MessPlainSignIn style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=100 alt=MessPlainSignIn src="http://byfiles.storage.msn.com/y1px5t4R_ak3zSMp9a82MsgRIEvp90pdAFRD5dqHBoe3h2f1PiLV7fb405B94RepeBjxz5lh5CVygQ?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;p&gt;So now that you’ve got the sign-in control displayed in your User Control, what can you do with it?  Well there are a few options that allow you customize certain parts of the control and get some default information. First off we’ll take a look at the Links collection :- &lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pzOqT0CRxg_U18p_GeJkE6Y1SfRekoiSK2XVCAswXFXdQi01WwF2qBuyWhTRX6ocPHkNt-osKNu4?PARTNER=WRITER"&gt;&lt;img title=MessLinksProperties style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=227 alt=MessLinksProperties src="http://byfiles.storage.msn.com/y1pPf9j1RbtcvgTBunhXaljzNmYp5Zy-Na7Hk0XC4UYqx_7SzB7y2cAfK-ySnniZPk8F718Rx-RURE?PARTNER=WRITER" width=126 border=0&gt;&lt;/a&gt;  &lt;p&gt;As you can see the links collection supplies you with a bunch of different URL’s to various Microsoft pages relating to either the messenger control or a users’ passport account.   &lt;p&gt;Here’s a brief description of what the various links hold :- &lt;ul&gt; &lt;li&gt;AboutMessengerUrl gets the URL for the Windows Live Messenger Overview page. Here your users can learn more about the Windows Live Messenger service.  &lt;li&gt;ChangeAccountUrl gets the URL for the Windows Live ID Sign In page where your users can choose the Windows Live ID account to sign in with.  &lt;li&gt;PrivacyUrl gets the URL for the Microsoft Online Privacy Statement (not the privacy statement page you had to include as part of the Sign-In control).  &lt;li&gt;ReportAbustUrl gets the URL for the Windows Live Messenger Abuse reporting form.  &lt;li&gt;SettingsUrl gets the URL for the Settings page where your users can set their Windows Live ID preferences.  &lt;li&gt;SignUpUrl gets the URL for the Windows Live ID Sign Up page where your users can sign up for a new Windows Live ID account.  &lt;li&gt;TermOfUseUrl gets the URL for the Windows Live Help page that contains the Terms of Use as defined in the Microsoft Service Agreement. &lt;/ul&gt; &lt;p&gt;  &lt;p&gt;The links collection becomes available to you after successful sign-in, and not until that point. So if we take a look at the code that we already have then you’ll see that we already have a function that gets called once sign-in has been completed.  All that we need to do is place a call to our function to get the links in there :- &lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;function&lt;/span&gt; signInCompleted(sender, e)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        &lt;span style="color:blue"&gt;if&lt;/span&gt; (e.get_resultCode() === Microsoft.Live.Messenger.SignInResultCode.success)&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        {&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            &lt;span style="color:blue"&gt;var&lt;/span&gt; selectStatus = $get(&lt;span style="color:#a31515"&gt;'selectStatus'&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            selectStatus.selectedIndex = 6;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;            getMessengerLinks();&lt;/pre&gt;&lt;pre style="margin:0px"&gt;        }&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    }&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;If you take a look at the Sign-In Control API then you’ll notice that there are three properties that we can use. All of them are getters :-
&lt;p&gt;&lt;a href="http://byfiles.storage.msn.com/y1pHGKTa6q7Jyb2xDOA4kuZj3SCVKls22C8fYyZ6GVwxDSQ5XUWdKVoy_4q0uvxuIvQGPjHahwH2Dg?PARTNER=WRITER"&gt;&lt;img title=MessSignInAPI style="border-top-width:0px;display:inline;border-left-width:0px;border-bottom-width:0px;border-right-width:0px" height=81 alt=MessSignInAPI src="http://byfiles.storage.msn.com/y1pW6MA4LqIBVFDiPSnqlMOruiNHg-MRLvVOxl_EQl4PGQGH9h0Z17y49g0_hTlb_7Cq7SSWRJCG80?PARTNER=WRITER" width=426 border=0&gt;&lt;/a&gt; 
&lt;p&gt;The one we’re interested in at the moment is the Links getter method. First off, lets add a section to our base Messenger framework where we will place these links. 
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;div&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;signinlinks&amp;quot;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;span&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;target&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;_blank&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;about&amp;quot;&amp;gt;&lt;/span&gt;About&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;target&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;_blank&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;privacy&amp;quot;&amp;gt;&lt;/span&gt;Privacy&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;target&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;_blank&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;reportAbuse&amp;quot;&amp;gt;&lt;/span&gt;ReportAbuse&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;target&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;_blank&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;termsofUse&amp;quot;&amp;gt;&lt;/span&gt;Terms Of Use&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;target&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;_blank&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;changeAccount&amp;quot;&amp;gt;&lt;/span&gt;Change Account&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;target&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;_blank&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;settings&amp;quot;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/Passport.gif&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;PassportImage&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt; &lt;span style="color:red"&gt;href&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;target&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;_blank&amp;quot;&lt;/span&gt; &lt;span style="color:red"&gt;id&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;signUp&amp;quot;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;img&lt;/span&gt; &lt;span style="color:red"&gt;src&lt;/span&gt;&lt;span style="color:blue"&gt;=&amp;quot;WebMessenger/Images/SignUp.gif&amp;quot;&lt;/span&gt; &lt;span style="color:blue"&gt;/&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;span&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515"&gt;div&lt;/span&gt;&lt;span style="color:blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;and add some styling to it in our style sheet :-
&lt;p&gt; 
&lt;div style="font-size:10pt;background:white;color:black;font-family:courier new"&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:#a31515"&gt;#signinlinks&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;width&lt;/span&gt;: &lt;span style="color:blue"&gt;100%&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;position&lt;/span&gt;: &lt;span style="color:blue"&gt;relative&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;text-align&lt;/span&gt;: &lt;span style="color:blue"&gt;right&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;display&lt;/span&gt;: &lt;span style="color:blue"&gt;none&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;pre style="margin:0px"&gt;&lt;span style="color:#a31515"&gt;#signinlinks&lt;/span&gt; &lt;span style="color:#a31515"&gt;span&lt;/span&gt; &lt;span style="color:#a31515"&gt;a&lt;/span&gt;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;{&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;font-family&lt;/span&gt;: &lt;span style="color:blue"&gt;Tahoma,arial,sans-serif&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;font-size&lt;/span&gt;:&lt;span style="color:blue"&gt;9px&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;text-decoration&lt;/span&gt;: &lt;span style="color:blue"&gt;none&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;text-indent&lt;/span&gt;: &lt;span style="color:blue"&gt;2px&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;    &lt;span style="color:red"&gt;color&lt;/span&gt;: &lt;span style="color:blue"&gt;#000000&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="margin:0px"&gt;}&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;Next we need to code our Javascript function that will get the links collection and parse it out to our various links. As mentioned this is a property getter m