I am on a roll. Since I tinkered with some client-based programming here as part of a small weekend project, I suddenly get this huge urge to do some more geeky client-GUI stuff.
I have generally been doing much of my work in the distributed systems area and therefore are known to be much of a server guy or a (W3C) SOAP, XML geek to many. However, like many of people who has ventured into the software development world of Windows, it usually starts at the desktop...and for me, it is VB3 - VB6, including VBA. OK, I risk the MFC, C++, Java, C# people spitting at me here so I better stop.
Anyways, I have always love the Internet Messenger (IM) and the genre of Presence Technology it brings. To think that if I had those technologies back in the late eighties while I was away in university in Canada, I wouldnt be writing those huge 'costly' paper stacks of letters to my folks back at home every week and I would still have kept in contact with my childhood friends. Hey, what can I say, I was too lazy to write them...
MSN Messenger is what I have always used as my IM, and then again, I have not used any other. It is currently in Version 7 at the moment and the enhancements that come with each version never seem to amaze me.
However, one pet peeve I have is the "Turn on What I am listening to" feature which I think, in my opinion, is for people with a narcissistic streak in them. There is nothing that turns me off than to imagine all the contacts in my list displaying the songs they are listening to at that moment. I dont know about you BUT I would be hugely embarrased if I have Britany Spears's I Am Not A Girl, Not Yet A Woman on my playlist.
So, I thought I do some mucking around with the MSN Messenger Window to see if I could do some Windows SubClassing into its Windows Handle. For all those of you who dont know the essentials of Windows are, I took the liberty to quote Aaron Ballman from his link I have referenced above:
All GUI applications on Windows are driven by getting messages from the operating system, and translating them into events for the user to handle. So when the mouse moves, a window is given a message telling it that the mouse has moved, and here are its current coordinates. Or when the user presses a key, a different message is generated and a window is alerted. This message dispatching is how all events are fired in REALbasic -- the system lets the framework know something has happened, and the framework passes the information along to you in the form of an event.
If you are going to try writing a GUI component in REALbasic, you will most likely need a way to hook into this magic function that the OS calls in order to receive notifications of what the user is doing. For example, if you wanted to write a TrayIcon class you might want to be notified when your icon is double-clicked on so that you can fire an action event. Before we get into the details of how to accomplish this, you should be brought up to speed on the terminology and concepts involved.
If you're coming from the world of C/C++, .NET or even Visual Basic, the magic function being described may be familiar to you. It is traditionally called a WndProc (pronounced 'wind-proc') and it's short for window procedure. You let the system know what WndProc to call by specifying one in a window's class definition (called a WNDCLASS) structure, which is then registered with the system. Every window created with that class definition will have its WndProc called by the system for all messages. The OS knows when to call the WndProc because there's a loop in the application known as the message pump which handles all the message passing. A typical message pump will look something like this (in C):
I had done some of those Windows programming before back when I had more hair so this is not a foreign concept to me. I dug out my old Win32 API Programming book to get myself acquainted with all the Windows Handles API again. I must say that I really enjoyed that as it did bring a sense of nostalgia to me. All the technical documentation about Windows Handles, Message Pumps, Windows Subclassing, Function and Memory Pointers and \0String Buffers\0 did get me excited for a while.
Then, I took a couple of nights off from sleeping (Hey, I have a real job...) and started doing some programming work against the .NET Framework...and before you know it, I have cooked up something that I would humbly think is quite respectable. Check out the screenshots on this page. OK, I admit the Application UI is nothing to shout about and I am ashamed to say I have failed Design, Usability and Color-Coordination 101 lessons in school. .
Basically, I allow the user to feed into the MSN Messenger their current location (I will explain more later...), the host machine's date, time and timezone as well as some user-defined caption. Since there is a clock element involved, I had to add a timer to constantly update MSN Messenger on the current time. The timer frequencies can be set as 1, 5, 10 seconds and 1, 5, 10 minutes. And for those who have some bandwidth restrictions (I believe MSN Messenger sends a packet over the network to inform all your contact list on you next message text), there is a UPDATE ONLY ONCE feature that updates once and then disables the timer.
As for the location, as I have many contacts on my list who travels frequently and they like to put their current location on my MSN Caption, so I figured this would be a useful feature and I wanted to make it automatic with no user intervention. I then wrote up a simple Where Am I Web Service that returns the Country name and code of your current location based on your IP address. An IP address is pretty accurate in telling your current whereabouts country-wise. Your IP address that you sent to my Where Am I service would be the public-interfacing IP address of your Wide-Area-Network. In this sense, you could be booting up this little application in Japan, Panama, Canada or the US and it would return your current host country automatically.
(On a more geeky note, I have invoked this Where Am I Web Service asynchronously [not via a duplex channel], so there is no Freeze-Hanging effect once this application is loaded. It really is quite cool to see your host country being reflected in your application once it returns from the service)
Now, wouldnt it be much more cooler to display all these Location and Time settings on your MSN instead of showing off what you are listening to ? Now, if everyone uses this tool, it would be nice to see everyone on my contact list from all over the different countries from all the (5 ? 6 ? or is it 7 ?) continents in the world.
I also played around with the system.diagnostics and processes a bit so that ONLY one instance of the application be loaded at only one time. This is really one of those rare times that I have done development work without any considerations for object pooling, scalability, load-balancing and the handling of muliple connections, etc that comes with the domains of distributed systems. Way cool. I like it !!!
I added some enhacements to it as I figured that there are way more narcissistic people than I think there are. (Oh, btw, I am blogging --- Am I narcissistic then ?) BUT I had to think of something more useful and functional. Then I realized maybe people would want to show what they are currently working on at the moment. This could be done via the Active Window Handle API. You could then show off to your boss that you are currently working on your assignment at the moment. However, do take note, you would be announcing to everyone that you are surfing for Internet Pornography as well so use this feature with care...
Of course, all these features can be turned on and off with a knob. Anyways, I have tested this with Windows XP and 2003 Server and it works. Other than that, you are on your own. You would also need the Microsoft .NET Framework 1.1 for this. You can get it via your Windows Update or download it here. Since this is freeware, please read the license before downloading and installing it.
Download it here now. Enjoy !
- To add more features
- Someone mentioned to me to show the current available computer memory at the moment. This could be bragging rights for someone with a 2 or 4GB RAM Machine or someone who is willing to contribute their system resources to the SETI @ Home Project. Let me know via comments on this post if you would like this feature.
- I dont really know how to remove that irritating headphone icon thingy. Let me know via comments on this post if you know how or could offer any advice.
- Hyperlink the text. Again, I dont really know how to do this so I would appreciate any advice and such.
I hope this serves as some kind of feedback to the MSN team as well so they know what to include for MSN Messenger 8 next time.