Monday, October 12, 2009

Yahoo Messenger Protocol

Recently I had to update a client messenger SDK so that it can log in to Yahoo Messenger service because Yahoo changed their messenger protocol and they no longer support older versions of the protocol. The latest YM9 uses YMSG v16, whereas the messenger SDK that I had to update used v12. So, I had to analyze and change quite a lot of things like login mechanism, buddy list parsing, presence, contact authorization, messaging etc. The login mechanism is explained here. I also found help by looking into Pidgin/Libpurple source code.

Saturday, March 28, 2009

Multi-User Chat XEP-0045

I have been working on implementing XEP-0045 lately. This is an extension for XMPP protocol that enables multi-user chat or room chat. You can find the specification here:
http://xmpp.org/extensions/xep-0045.html

Sunday, February 8, 2009

Browser Helper Objects

Recently I worked on a small project where I had to make a Browser Helper Object(BHO) for Internet Explorer. BHOs are also known as add-ons. A BHO is like a plugin that is loaded automatically whenever IE is loaded or a new tab (IE7) is opened. It's amazing how useful a BHO can be. I found this tutorial useful to get started:
Building Browser Helper Objects with Visual Studio 2005

Saturday, November 8, 2008

File Icon from File Extension

First I tried to find the icon by searching the registry. Like, for .txt files, go to ".txt" under HKEY_CLASSES_ROOT, then see what is written for "(Default)", in this case, "txtfile". Again find "txtfile" under HKEY_CLASSES_ROOT and look into the "DefaultIcon" subkey to find the filename and index of the icon for this type of files. Then extract the icon with Win32 API.

That's a lot of work and unfortunately, this approach does not work for all file extensions, because some extensions have custom IconHandlers (don't really know what that means though). Then I found a better and neater way to do it by using the SHGetFileInfo function. You just need to give the file extension and set the flags appropriately to get the job done. Don't forget to call DestroyIcon on the HICON after you are done with it.

Saturday, November 1, 2008

Preventing Horizontal Scrollbar in Browser

This is another simple solution that can be done using HTML/CSS. If you want to force the WebBrowser control to wrap the page contents so that the horizontal scrollbar never appears, you can do it by adding the style "word-wrap: break-word;" to your BODY tag.

Preventing Image Drag from Browser

If you just want to prevent users from dragging an image from your hosted WebBrowser control, there is no need to implement IDropSource or anything. You can do this by simply adding
onmousemove='return false;' to your IMG tag. I wasted a lot of time on this, but it has nothing to do with the WebBrowser control, all you need is this simple HTML/JavaScript snippet.

WebBrowser Control Customization

The WebBrowser control is a very useful control for showing rich content in your application. It can be customized to suit your needs. I was able to customize the context menu and add drag and drop feature by implementing the interfaces IOleClientSite, IDocHostUIHandler and IDropTarget. See the WebBrowser Customization tutorial on MSDN for details. Here is another very helpful link to a sample project regarding context menu customization.