<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>:nanoANT: Home of the productive microscopic ants</title>
	<atom:link href="http://www.nanoant.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.nanoant.com</link>
	<description>Yet another self-employee site &#38; blog</description>
	<pubDate>Tue, 19 Aug 2008 16:29:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>jabberd2 2.2SVN for Windows is out</title>
		<link>http://www.nanoant.com/projects/jabberd2-22svn-for-windows-is-out</link>
		<comments>http://www.nanoant.com/projects/jabberd2-22svn-for-windows-is-out#comments</comments>
		<pubDate>Mon, 18 Aug 2008 15:20:22 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Jabber]]></category>

		<category><![CDATA[Projects]]></category>

		<category><![CDATA[jabberd2]]></category>

		<category><![CDATA[windows]]></category>

		<category><![CDATA[xmpp]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/?p=40</guid>
		<description><![CDATA[jabberd2 win32 project is finally updated and synced with changes made in the generic Unix code. New changes should bring improved compatibility &#38; stability and new 2.2 features for Windows users. Binary installer and optional build instructions available as usual at jabberd-win32 page. Click more for changes.
Changes:

FIX: Setup files were not anymore compatible with latest [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jabberd2.xiaoka.com/">jabberd2</a> win32 project is finally updated and synced with changes made in the generic <em>Unix</em> code. New changes should bring improved compatibility &amp; stability and new 2.2 features for <em>Windows</em> users. Binary <a href="http://www.nanoant.com/projects/jabberd2-win32#download">installer</a> and optional build instructions available as usual at <a href="http://www.nanoant.com/projects/jabberd2-win32">jabberd-win32</a> page. Click more for changes.<span id="more-40"></span></p>
<p>Changes:</p>
<ul>
<li><em>FIX:</em> Setup files were not anymore compatible with latest <a href="http://wix.sourceforge.net/releases/">WiX</a> 3 beta</li>
<li><em>FIX</em>: Router failing opening users and filters configuration in Windows</li>
<li><em>FIX:</em> Mysql missing <tt>crypt</tt> is replaced with <tt>DES_crypt</tt> from <a href="http://www.slproweb.com/products/Win32OpenSSL.html">OpenSSL</a> in Windows</li>
<li><em>NEW:</em> Compressed stream support via <a href="http://www.zlib.net/">zlib</a></li>
<li><em>NEW:</em> Keep <tt>server.pem</tt> on upgrades</li>
<li><em>NEW:</em> Using <tt>SubWCRev</tt> from <a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a> for version files generation (instead of <tt>xsltproc</tt>)</li>
<li><em>NEW:</em> All configuration files are now generated on build by Perl from generic distribution ones</li>
<li><em>NEW:</em> Using <a href="http://www.corpit.ru/mjt/udns.html">udns</a> library for Windows builds too (<em>resolver</em> component was removed)</li>
<li><em>UPDATE:</em> Synced <tt>config.h</tt> with the one from generic builds</li>
</ul>
<p>All changes are visible as SVN revisions 644-688 in <a href="http://jabberd2.xiaoka.com/browser/trunk">the repository</a>.</p>
<p>Please note new build prerequisites such as <a href="http://www.corpit.ru/mjt/udns.html">udns</a>, <a href="http://www.zlib.net/">zlib</a>, <em>Perl</em> and <a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a> for manual builds.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/projects/jabberd2-22svn-for-windows-is-out/feed</wfw:commentRss>
		</item>
		<item>
		<title>Perfect Terminal.app Unicode font</title>
		<link>http://www.nanoant.com/tweaks/perfect-terminalapp-unicode-font</link>
		<comments>http://www.nanoant.com/tweaks/perfect-terminalapp-unicode-font#comments</comments>
		<pubDate>Fri, 20 Jun 2008 11:14:01 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Tweaks]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/?p=27</guid>
		<description><![CDATA[Since I switched to Mac OS X &#38; Terminal.app I have started using UTF-8 code-page for all my terminal sessions; Mac local and Linux/UNIX remote.
After few months spent with Apple&#8217;s Monaco font, unfortunately not in Monaco, and few hours of fighting with FontForge I have finally made up great bitmap 9&#215;18 font for my terminal.

(Using new Fixed font with 18pt size [...]]]></description>
			<content:encoded><![CDATA[<p>Since I switched to <em>Mac OS X</em> &amp; <em>Terminal.app</em> I have started using UTF-8 code-page for all my terminal sessions; <em>Mac</em> local and <em>Linux/UNIX</em> remote.</p>
<p>After few months spent with Apple&#8217;s <em>Monaco</em> font<em>, </em>unfortunately not in <em>Monaco</em>, and few hours of fighting with <a href="http://fontforge.sourceforge.net/">FontForge</a> I have finally made up great bitmap 9&#215;18 font for my terminal.</p>
<p><img src="http://www.nanoant.com/screenshots/mac/TerminalFixedFont.png" alt="My new Terminal.app FixedMedium.dfont" width="638" height="396" /></p>
<p><span id="more-27"></span>(Using new Fixed font with 18pt size with vertical spacing set to 0.80, no antialiasing)</p>
<p>Here is my story&#8230; First I have used famous <em>Monaco</em> Apple font, which was doing really great. However I have noticed that while on normal ANSI session of mc (<em>Midnight Commander</em>) <em>Monaco</em>&#8217;s box drawing is OK, while on UTF mc (<em>ncurses</em>) are using UNICODE box drawing characters (0&#215;2500) which look awful with <em>Monaco</em>, the reason is that vertical box lines are not continuos divided by line spacing.</p>
<p>Since anyway I don&#8217;t use antialiasing in the terminal, I have started looking for perfect bitmap console font that contains maximum number of UNICODE ranges (including my Polish characters), and I have found great X11 font package by Markus Kuhn at <a href="http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html">http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html</a></p>
<p>I have used <a href="http://fontforge.sourceforge.net/">FontForge</a> (from <em>MacPorts</em>) to produce following <em>dfont</em>s below.</p>
<h3>Download</h3>
<ul class="projects">
<li class="font_bitmap"><a href="http://www.nanoant.com/download/fonts/FixedMedium.dfont">FixedMedium.dfont</a> 2008-06-20, 312 KB, <em>Fixed</em> medium bitmap font sizes: 13, 14, 15, 18</li>
<li class="font_bitmap"><a href="http://www.nanoant.com/download/fonts/FixedBold.dfont">FixedBold.dfont</a> 2008-06-20, 64 KB, <em>Fixed</em> bold bitmap font sizes: 13, 14, 15, 18</li>
</ul>
<h3>License</h3>
<p>You are free to use, distribute or modify fonts provided here. I disclaim any warranties with regard to this font. This work is derieved from UCS fonts available from Markus Kuhn at: <a href="http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html">http://www.cl.cam.ac.uk/~mgk25/ucs-fonts.html</a></p>
<h3>Important</h3>
<p>In order to have continuos vertical line drawing with this <em>Fixed</em> font you need to reduce vertical line spacing to ~0.80 (as for 18pt size) in Terminl.app font settings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/tweaks/perfect-terminalapp-unicode-font/feed</wfw:commentRss>
		</item>
		<item>
		<title>New year&#8217;s jabberd2 Windows build has arrived</title>
		<link>http://www.nanoant.com/projects/new-years-jabberd2-windows-build-arrived</link>
		<comments>http://www.nanoant.com/projects/new-years-jabberd2-windows-build-arrived#comments</comments>
		<pubDate>Tue, 29 Jan 2008 23:23:59 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Jabber]]></category>

		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/projects/new-years-jabberd2-windows-build-arrived</guid>
		<description><![CDATA[I have recently moved to new platform, Mac OS X and MacBook Pro. I must say I&#8217;m pretty happy with both. I&#8217;m learning new things, like Cocoa programming, playing with new nice interface and applications, and almost forgot about some of my Windows projects like jabberd2 win32, and updating my site of course  
Fortunately [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently moved to new platform, <a href="http://www.apple.com/macosx/">Mac OS X</a> and <a href="http://www.apple.com/macbookpro/">MacBook Pro</a>. I must say I&#8217;m pretty happy with both. I&#8217;m learning new things, like <em>Cocoa</em> programming, playing with new nice interface and applications, and almost forgot about some of my <em>Windows</em> projects like <a href="/projects/jabberd2-win32">jabberd2 win32</a>, and updating my site of course <img src='http://www.nanoant.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><img src="http://www.adiumx.com/images/logo.png" alt="Adium" align="right" height="128" width="128" />Fortunately <a href="http://www.adiumx.com/">Adium</a>, the great <em>Mac OS X</em> IM client, made me remember, as it was regularly complaining about inability to make a connection to my company XMPP server running jabberd2 <em>Windows</em> version of mine. Also <a href="http://staff.xiaoka.com/smoku/">Tomasz Sterna</a>, current maintainer of <a href="http://jabberd2.xiaoka.com/">jabberd2</a>, pointed me some win32 bugfixes hanging on mailing list. So there&#8217;s an interest in what I&#8217;m doing here! It is alive! Alive!</p>
<p>Going back to the subject, I&#8217;ve sat myself for a few (or little more) hours back to <em>Windows</em> and <em>Visual Studio</em>, made latest trunk compile properly in <em>Visual Studio 2005</em> and finally killed all those annoying bugs that made <a href="/projects/jabberd2-win32">jabberd2 win32</a> so unstable. So here it is, you can find brand new build.. working with <a href="http://www.adiumx.com/">Adium</a>, and the others I hope. Still you need to remember to install <a href="/projects/jabberd2-win32#download">VS2005</a> and <a href="/projects/jabberd2-win32#download">OpenSSL</a> runtimes before running my installer or it gonna fail. I hope I can make it somehow better soon, like having some message popping up about those runtime libraries in the installer.</p>
<p>Also as a side-effect of my work there are <em>Visual Studio 2005</em> compatible versions of <a href="http://www.gnu.org/software/gsasl/">libgsasl</a> and <a href="http://www.gnu.org/software/libidn/">libidn</a> there in the <a href="/projects/jabberd2-win32#download">downloads</a>, so hope I did something good for the community and I can sleep well now. Good night.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/projects/new-years-jabberd2-windows-build-arrived/feed</wfw:commentRss>
		</item>
		<item>
		<title>Fixed XML bug in jabberd2 win32 installer</title>
		<link>http://www.nanoant.com/projects/fixed-xml-bug-in-jabberd2-win32-installer</link>
		<comments>http://www.nanoant.com/projects/fixed-xml-bug-in-jabberd2-win32-installer#comments</comments>
		<pubDate>Mon, 06 Aug 2007 12:47:37 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Jabber]]></category>

		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/projects/fixed-xml-bug-in-jabberd2-win32-installer</guid>
		<description><![CDATA[Three days ago I have released first public MSI installer of jabberd2, however small bug sneaked in that disallowed installing clean version: ?Failed to open XML file c:\Program Files\jabberd2\\c2s.dist.xml, system error -2147024786?.
Now it is fixed in both SVN and downloads of jabberd2 win32. Sorry for the problem, now I hope you can enjoy at last [...]]]></description>
			<content:encoded><![CDATA[<p>Three days ago I have released first public MSI installer of <a href="http://jabberd2.xiaoka.com/">jabberd2</a>, however small bug sneaked in that disallowed installing clean version: <em>?Failed to open XML file c:\Program Files\jabberd2\\c2s.dist.xml, system error -2147024786?</em>.</p>
<p>Now it is fixed in both SVN and <a href="/projects/jabberd2-win32#download">downloads of jabberd2 win32</a>. Sorry for the problem, now I hope you can enjoy at last <em>jabberd2 for Windows</em> installer. <img src='http://www.nanoant.com/wp/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/projects/fixed-xml-bug-in-jabberd2-win32-installer/feed</wfw:commentRss>
		</item>
		<item>
		<title>Here goes jabberd2 MSI installer</title>
		<link>http://www.nanoant.com/projects/here-goes-jabberd2-msi-installer</link>
		<comments>http://www.nanoant.com/projects/here-goes-jabberd2-msi-installer#comments</comments>
		<pubDate>Fri, 03 Aug 2007 13:19:41 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Jabber]]></category>

		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/projects/here-goes-jabberd2-msi-installer</guid>
		<description><![CDATA[After few evenings of playing with WiX toolset for MSI installers I have finally committed setup projects into SVN source of jabberd2. You can also find brand new installer of jabberd2 SVN #333 revision in downloads on my jabberd2 win32 page.
It is not yet super-perfect, however it respects upgrades, also it will NOT overwrite your [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.nanoant.com/screenshots/jabberd2-win32/installer.png" title="Installer screenshot" alt="Installer screenshot" align="right" border="0" height="195" hspace="10" width="250" />After few evenings of playing with <a href="http://wix.sourceforge.net/">WiX</a> toolset for <em>MSI</em> installers I have finally committed setup projects into SVN source of <a href="http://jabberd2.xiaoka.com/">jabberd2</a>. You can also find brand new installer of <em>jabberd2 SVN #333</em> revision in downloads on my <a href="/projects/jabberd2-win32#download">jabberd2 win32</a> page.</p>
<p>It is not yet super-perfect, however it respects upgrades, also it will NOT overwrite your existing jabberd2 configuration nor database files.</p>
<p>Installer running on fresh jabberd2 free system will ask for <em>XMPP</em> domain during setup process and install running jabberd2 configuration using <em>SQLite</em> backend for authentication and storage with registration enabled. After installation remember you need to restart <tt>jabber2comp</tt> service every time you change <tt>comp.xml</tt> file (where comp may be <tt>s2s</tt>, <tt>c2s</tt>, <tt>router</tt>, <tt>resolver</tt> or <tt>sm</tt>).</p>
<p>Running installer over existing jabberd2 installation will result only with upgrading binary files and writing new <tt>*.dist.xml</tt> files next to existing <tt>*.xml</tt> ones.</p>
<p>Have fun with <a href="http://jabberd2.xiaoka.com/">jabberd2</a>! Don&#8217;t forget to install <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=200B2FD9-AE1A-4A14-984D-389C36F85647&amp;displaylang=en">Visual C++ 2005 Runtime Libraries</a> prior running the setup.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/projects/here-goes-jabberd2-msi-installer/feed</wfw:commentRss>
		</item>
		<item>
		<title>Multi-User Conferencing for Windows released</title>
		<link>http://www.nanoant.com/projects/muc-for-windows-released</link>
		<comments>http://www.nanoant.com/projects/muc-for-windows-released#comments</comments>
		<pubDate>Sat, 16 Jun 2007 10:34:20 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Jabber]]></category>

		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/projects/jabber/muc-for-windows-released</guid>
		<description><![CDATA[Here goes the new test release of mu-conference for Windows, complementary to first jabberd2 for Windows releases from the beginning of the June. Binaries (only 1.05MB) available from my page are configured to work seamlessly with jabberd2 Windows builds, so only host name change and simple service installation as described in the guide are needed [...]]]></description>
			<content:encoded><![CDATA[<p>Here goes the new test release of <a href="/projects/muc-win32">mu-conference for Windows</a>, complementary to first <a href="/projects/jabberd2-win32">jabberd2 for Windows</a> releases from the beginning of the June. Binaries (only 1.05MB) available from <a href="/projects/muc-win32">my page</a> are configured to work seamlessly with <a href="/projects/jabberd2-win32">jabberd2 Windows builds</a>, so only host name change and simple service installation as described in <a href="/projects/muc-win32">the guide</a> are needed to run conferences within your <em>jabberd2</em> server on <em>Windows</em>.</p>
<p>Several users already confirmed running <em>jabberd2</em> on <em>Windows</em> server platform with success (I am running it also at my company). And now <em>mu-conference</em> component will be nice addendum to this light XMPP server suite, as together with <em>jabberd2</em> all takes ~6MB on the disk with no extra software required!</p>
<p>P.S. <em>Windows</em> MSI installer is also on the way. Soon <a href="http://jabberd2.xiaoka.com/">jabberd2</a> XMPP server installation will be even easier. <img src='http://www.nanoant.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/projects/muc-for-windows-released/feed</wfw:commentRss>
		</item>
		<item>
		<title>Themed menu&#8217;s icons, a complete Vista and XP solution</title>
		<link>http://www.nanoant.com/programming/themed-menus-icons-a-complete-vista-xp-solution</link>
		<comments>http://www.nanoant.com/programming/themed-menus-icons-a-complete-vista-xp-solution#comments</comments>
		<pubDate>Tue, 12 Jun 2007 15:43:01 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/programming/themed-menus-icons-a-complete-vista-xp-solution</guid>
		<description><![CDATA[I&#8217;m an author of few patches for both Tortoise SVN and Tortoise CVS that makes them display the explorer&#8217;s context menu icons nicely on XP and Windows 2000. Both programs are implementing IContextMenu and using QueryContextMenu function to create items of popup menu of explorer. Briefly the called extension must fill menu items with InsertMenuItem [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m an author of few patches for both <a href="http://tortoisesvn.tigris.org/">Tortoise SVN</a> and <a href="http://www.tortoisecvs.org/">Tortoise CVS</a> that makes them display the explorer&#8217;s context menu icons nicely on <em>XP</em> and <em>Windows 2000</em>. Both programs are implementing <tt>IContextMenu</tt> and using <tt>QueryContextMenu</tt> function to create items of popup menu of explorer. Briefly the called extension must fill menu items with <tt>InsertMenuItem</tt> using suplied <tt>HMENU hmenu</tt> parameter.</p>
<p>During development of those few patches I&#8217;ve learnt some few new things about way we make icons displayed next to menu items I want to share with you&#8230; <span id="more-18"></span></p>
<h2>How to get icons in context menus</h2>
<p>Methods described here are related to shell context menu extension, however they can be used in any <em>Windows</em> application.</p>
<h3>hbmp(Un)checked method</h3>
<p><img src="/screenshots/tortoise/TortoiseCVS-hbmpUnchecked.png" title="Old Tortoise CVS menu icons" alt="Old Tortoise CVS menu icons" align="right" height="85" hspace="10" width="211" />Initially both <em>Tortoises</em> were filling <tt>hbmpUnchecked</tt> &amp; <tt>hbmpChecked</tt> fields of <tt>MENUITEMINFO</tt> that is passed to <tt>InsertMenuItem</tt> with <tt>HBITMAP</tt> created from icon to get icons on menu item. This solution works on all <em>Windows</em> since 95. However the strong limitation is that <tt>HBITMAP</tt> must be <tt>SM_CXMENUCHECK</tt> x <tt>SM_CYMENUCHECK</tt> (usually 12 x 12). So if you are using 16 x 16 icon, the icon gets squished and looks awfully. The function used to convert icon to bitmap is:</p>
<pre><code class="cpp">HBITMAP CShellExt::IconToBitmap(std::string sIcon)
{
	RECT rect;

	rect.right = ::GetSystemMetrics(SM_CXMENUCHECK);
	rect.bottom = ::GetSystemMetrics(SM_CYMENUCHECK);

	rect.left = rect.top  = 0;

	HICON hIcon = (HICON)LoadImageA(g_hInstance, sIcon.c_str(), IMAGE_ICON, rect.right, rect.bottom, LR_DEFAULTCOLOR);
	if (!hIcon)
		return NULL;

	HWND desktop = ::GetDesktopWindow();
	if (desktop == NULL)
	{
		DestroyIcon(hIcon);
		return NULL;
	}

	HDC screen_dev = ::GetDC(desktop);
	if (screen_dev == NULL)
	{
		DestroyIcon(hIcon);
		return NULL;
	}

	// Create a compatible DC
	HDC dst_hdc = ::CreateCompatibleDC(screen_dev);
	if (dst_hdc == NULL)
	{
		DestroyIcon(hIcon);
		::ReleaseDC(desktop, screen_dev);
		return NULL;
	}

	// Create a new bitmap of icon size
	HBITMAP bmp = ::CreateCompatibleBitmap(screen_dev, rect.right, rect.bottom);
	if (bmp == NULL)
	{
		DestroyIcon(hIcon);
		::DeleteDC(dst_hdc);
		::ReleaseDC(desktop, screen_dev);
		return NULL;
	}

	// Select it into the compatible DC
	HBITMAP old_dst_bmp = (HBITMAP)::SelectObject(dst_hdc, bmp);
	if (old_dst_bmp == NULL)
	{
		DestroyIcon(hIcon);
		return NULL;
	}

	// Fill the background of the compatible DC with the given colour
	::SetBkColor(dst_hdc, RGB(255, 255, 255));
	::ExtTextOut(dst_hdc, 0, 0, ETO_OPAQUE, &amp;rect, NULL, 0, NULL);

	// Draw the icon into the compatible DC
	::DrawIconEx(dst_hdc, 0, 0, hIcon, rect.right, rect.bottom, 0, NULL, DI_NORMAL);

	// Restore settings
	::SelectObject(dst_hdc, old_dst_bmp);
	::DeleteDC(dst_hdc);
	::ReleaseDC(desktop, screen_dev);
	DestroyIcon(hIcon);
	return bmp;
}</code></pre>
<h3>Ownerdraw method</h3>
<p><a href="http://tortoisesvn.tigris.org/">Tortoise SVN</a> was using also owner draw method. I won&#8217;t describe here details of this method. This relays on <tt>MENUITEMINFO</tt> <tt>fType</tt> flag set to <tt>MFT_OWNERDRAW</tt>. Shell extension in <tt>HandleMenuMsg2</tt> callback should handle <tt>WM_MEASUREITEM</tt> and <tt>WM_DRAWITEM</tt>.  This method is generally OK, however it has several flaws:</p>
<ol>
<li>We need to measure &amp; draw menu in all stated ourselves, which makes us write plenty of code.</li>
<li>Ownerdraw menus are not respecting visual styles of <em>Windows XP</em> or <em>Vista</em>. We would need to use uxtheme functions to somehow handle rendering of menu parts on those systems.</li>
<li>We need to keep exta context information for each menu item with text, icon handle, etc.</li>
<li>Keyboard shortcuts doesn&#8217;t work automatically, we must handle <tt>WM_MENUCHAR</tt> to make them work.</li>
</ol>
<h3>HBMMENU_CALLBACK method</h3>
<p>Since <em>Windows 98</em> <tt>MENUITEMINFO</tt> has extra field <tt>hbmpItem</tt>.  This field can be used for setting the <tt>HBITMAP</tt> with bitmap that is displayed next to the menu item. <tt>hbmpItem</tt> can be set also to <tt>HBMMENU_CALLBACK</tt> which will make menu item work like owner-draw, but <tt>WM_MEASUREITEM</tt> &amp; <tt>WM_DRAWITEM</tt> just need to handle icon drawing, rest will be done by <em>Windows</em>.  This method is easiest to implement and so it is used inside many application, I just name on I use or develop: <em>wxWidgets SDK,</em> <em>Miranda IM</em>. We just need to initialize menu item like that:</p>
<pre><code class="cpp">MENUITEMINFO menuiteminfo;
ZeroMemory(&amp;menuiteminfo, sizeof(menuiteminfo));
menuiteminfo.cbSize = sizeof(menuiteminfo);
menuiteminfo.fMask = MIIM_FTYPE | MIIM_ID | MIIM_SUBMENU | MIIM_DATA | MIIM_BITMAP | MIIM_STRING;
menuiteminfo.fType = MFT_STRING;
menuiteminfo.dwTypeData = lpszMenuTitle;
menuiteminfo.cch = _tcslen(lpszMenuTitle);
menuiteminfo.hbmpItem = HBMMENU_CALLBACK;
menuiteminfo.wID = id;</code></pre>
<p>Rest is done in <tt>WM_MEASUREITEM</tt> where we need to just make sure we have space for 16 x 16 image using:</p>
<pre><code class="cpp">	case WM_MEASUREITEM:
		{
			MEASUREITEMSTRUCT* lpmis = (MEASUREITEMSTRUCT*)lParam;
			if (lpmis==NULL)
				break;
			lpmis-&gt;itemWidth += 2;
			if (lpmis-&gt;itemHeight &lt; 16)
				lpmis-&gt;itemHeight = 16;
			*pResult = TRUE;
		}
		break;</code></pre>
<p>Then to draw an icon we need to handle WM_DRAWITEM, but just drawing the icon, nothing else:</p>
<pre><code class="cpp">	case WM_DRAWITEM:
		{
			LPCTSTR resource;
			DRAWITEMSTRUCT* lpdis = (DRAWITEMSTRUCT*)lParam;
			if ((lpdis==NULL)||(lpdis-&gt;CtlType != ODT_MENU))
				return S_OK; // not for a menu
			resource = GetMenuIconResourceID(lpdis-&gt;itemID);
			if (resource == NULL)
				return S_OK;
			HICON hIcon = (HICON)LoadImage(g_hResInst, resource, IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
			if (hIcon == NULL)
				return S_OK;
			DrawIconEx(lpdis-&gt;hDC,
				lpdis-&gt;rcItem.left - 16,
				lpdis-&gt;rcItem.top + (lpdis-&gt;rcItem.bottom - lpdis-&gt;rcItem.top - 16) / 2,
				hIcon, 16, 16,
				0, NULL, DI_NORMAL);
			DestroyIcon(hIcon);
			*pResult = TRUE;
		}
		break;</code></pre>
<p>Simple ? Yes it is. However there are some issues with this method as well:</p>
<ol>
<li>When this method is used on <em>Windows 2000</em> shell extension window background popup menu, then <tt>shell.dll</tt> is removing text from the menu, so we see just icons.
<p>This is obviously a bug of <em>Windows 2000</em> <tt>shell.dll</tt>, because MSDN documentation states this shall work regardless of the sittuation, but we need to somehow get over it. Surprisingly it does work fine when we right-click on explorer item (file or folder). The easiest solution is using <tt>hbmp(Un)checked</tt> method when <tt>uFlags == 0</tt> of <tt>QueryContextMenu</tt>, which indicated we clicked the background, so we fall back to most primitive method, but at least we got text and &#8220;some&#8221; icons in the menu.</p>
<p><strong>Note:</strong> This bug only appears in <em>Windows 2000</em> explorer&#8217;s background menu of shell extension, so in every other situation as standalone program menus <tt>HBMMENU_CALLBACK</tt> method can be used without any problem. So you may not care about it unless you are shell extension developer.</li>
<li><em>Vista</em> is removing menu theme when some menu item has <tt>hbmpItem</tt> set to <tt>HBMMENU_CALLBACK</tt>, so we will have nice icons and nice menu, but if we want to have nice icons with 100% themed menu on <em>Vista</em> we need to use last method&#8230;</li>
</ol>
<h3>Vista PARGB32 hbmpItem bitmap method</h3>
<p><em>Vista</em> strongly relays on 32-bit pre-multiplied alpha RGB bitmaps for rendering its interface. In Vista hbmpItem can be set to PARGB32 HBITMAP and this bitmap will be nicely displayed by Vista together with theming as you can see on the screenshot at right.  I got know of this possibility reading nice article <a href="http://shellrevealed.com/blogs/shellblog/archive/2007/02/06/Vista-Style-Menus_2C00_-Part-1-_2D00_-Adding-icons-to-standard-menus.aspx">Vista Style Menus, Part 1 - Adding icons to standard menus</a> at <em>ShellRevealed</em> blog.</p>
<p>The most important question is how to we get our icon (regardless it is 32-bit with alpha, or 256-color with mask) converted to PARGB32 HBITMAP. Windows API doesn&#8217;t give such possibility straight of the box.  Article from <em>ShellRevealed</em> proposes WIC (<em>Windows Imaging Component</em>) which is cool &amp; quite simple for conversion or <em>Vista</em>&#8217;s GDI method, but those require <em>Vista SDK</em>, which may be annoying for those using <em>Visual Studio</em>&#8217;s out of the box.</p>
<p>As an alternative to that I&#8217;ve used <em>Gdiplus</em> which is present on most of the systems since <em>Windows 2000</em>, and most shipped with <em>Visual Studio</em>s <em>Platforms SDK</em>s.  This method is also much simpler than WIC or GDI method from described article. My PARGB32 function is as follows:</p>
<pre><code class="cpp">HBITMAP CShellExt::IconToBitmapPARGB32(std::string sIcon)
{
	std::map&lt;UINT, HBITMAP&gt;::iterator bitmap_it = bitmaps.lower_bound(uIcon);
	if (!m_gdipToken)
		return NULL;
	HICON hIcon = (HICON)LoadImageA(g_hResInst, sIcon.c_str(), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
	if (!hIcon)
		return NULL;
	Bitmap icon(hIcon);
	Bitmap bmp(16, 16, PixelFormat32bppPARGB);
	Graphics g(&amp;bmp);
	g.DrawImage(&amp;icon, 0, 0, 16, 16);

	HBITMAP hBmp = NULL;
	bmp.GetHBITMAP(Color(255, 0, 0, 0), &amp;hBmp);

	return hBmp;
}</code></pre>
<p><img src="/screenshots/tortoise/TortoiseSVN-Vista-native-icons.jpg" title="Tortoise SVN dev trunk on Vista" alt="Tortoise SVN dev trunk on Vista" align="right" hspace="10" />So in this case instead <tt>menuiteminfo.hbmpItem = HBMMENU_CALLBACK</tt> we do <tt>menuiteminfo.hbmpItem = IconToBitmapPARGB32(lpszIconResourceID)</tt>. We shouldn&#8217;t forget of initializing Gdiplus library with <tt>GdiplusStartup(&amp;m_gdipToken, &amp;gdiplusStartupInput, NULL)</tt> in program/DLL initialization code and shutting it down after all with <tt>GdiplusShutdown(m_gdipToken)</tt>.</p>
<p>Since we are going to use <em>Gdiplus</em> only on <em>Vista</em>, we may use <tt>Gdiplus.dll</tt> as delayed load DLL, so it won&#8217;t be loaded on older systems using previous methods, saving us some memory.  Simple enough ?</p>
<p>Testing <em>Windows</em> version number with <tt>GetVersionEx</tt> and combining this method for <em>Vista</em> with <tt>HBMENU_CALLBACK</tt> method for <em>Windows XP</em> and older systems (with <tt>hbmp(Un)checked</tt> fallback on explorer extension on <em>Windows 2000</em> if needed) is my opinion best method of having nice menus in all modern <em>Windows</em> systems. This is also current display method of <a href="http://www.tortoisecvs.org/">Tortoise CVS</a> &amp; <a href="http://tortoisesvn.tigris.org/">Tortoise SVN</a> latest development versions. If you need full code to browse you may want look into <a href="http://tortoisesvn.tigris.org/">Tortoise SVN</a> SVN trunk files: <tt>src\TortoiseShell\ContextMenu.cpp</tt>, <tt>src\TortoiseShell\ShellExt.cpp</tt> and <tt>src\TortoiseShell\ShellExt.h</tt>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/programming/themed-menus-icons-a-complete-vista-xp-solution/feed</wfw:commentRss>
		</item>
		<item>
		<title>New approach to web design</title>
		<link>http://www.nanoant.com/publications/new-approach-to-web-design</link>
		<comments>http://www.nanoant.com/publications/new-approach-to-web-design#comments</comments>
		<pubDate>Mon, 11 Jun 2007 20:00:35 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Publications]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/publications/new-approach-to-web-design</guid>
		<description><![CDATA[Last week I gave a presentation of New approach to web design on my university about XHTML, XML and separation of the presentation (design) from document content (structure &#38; data). All Polish readers may find a copy of presentation in Polish here as Slidy presentation. Non-Polish readers shall excuse me. 
]]></description>
			<content:encoded><![CDATA[<p>Last week I gave a presentation of <em>New approach to web design</em> on my <a href="http://www.uj.edu.pl">university</a> about <em>XHTML</em>, <em>XML</em> and separation of the presentation (design) from document content (structure &amp; data). All Polish readers may find a copy of presentation in Polish <a href="http://www.nanoant.com/uj/Nowe%20podejscie%20do%20projektowania%20WWW.html">here as Slidy presentation</a>. Non-Polish readers shall excuse me. <img src='http://www.nanoant.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/publications/new-approach-to-web-design/feed</wfw:commentRss>
		</item>
		<item>
		<title>IE Dev Toolbar 1.00.2188.0 annoying popup fix</title>
		<link>http://www.nanoant.com/tweaks/ie-dev-toolbar-annoying-popup-fix</link>
		<comments>http://www.nanoant.com/tweaks/ie-dev-toolbar-annoying-popup-fix#comments</comments>
		<pubDate>Mon, 11 Jun 2007 19:44:57 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Tweaks]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/tweaks/ie-dev-toolbar-10-beta-3-annoying-error-fix</guid>
		<description><![CDATA[Some time ago Microsoft has released great addon to Internet Explorer called Internet Explorer Developer Toolbar. Latest version 1.00.2188.0 bring many great features, however it also brings huge annoyance with IE7 and any script debugger installed on system such as Visual Studio 2005 - an error popup asking for debugger selection every time we open [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago <em>Microsoft</em> has released great addon to <em>Internet Explorer</em> called <em>Internet Explorer Developer Toolbar</em>. Latest version 1.00.2188.0 bring many great features, however it also brings huge annoyance with IE7 and any script debugger installed on system such as <em>Visual Studio 2005</em> - an error popup asking for debugger selection every time we open new page. Want to know how to fix it?<span id="more-16"></span></p>
<h2>How to fix that ?</h2>
<p>It is possible to fix that with any good Resource Editor. Follow the recipe to get rid of popping up <em>JavaScript</em> error:</p>
<ol>
<li>Close all <em>Internet Explorer</em> windows.</li>
<li>Locate and extract <em>IE Dev Toolbar JavaScript</em> source using any resource editor. Open <tt>C:\Program Files\Microsoft\Internet Explorer Developer Toolbar\IEDevToolbar.dll</tt> and extract resource <tt>TXT/235/1033</tt> (type/resource ID/resource language). I used <a href="http://www.totalcmd.net/plugring/resextract.html">Resource Extractor</a> extension of <a href="http://www.totalcmd.com/">Total Commander</a>. Alternatively you can use <a href="http://www.wilsonc.demon.co.uk/d10resourceeditor.htm">XN Resource Editor</a>. I didn&#8217;t use <a href="http://www.angusj.com/resourcehacker/">Resource Hacker</a> for this because it was saving the resource as hex-dump rather than binary file.</li>
<li>Modify extracted <em>JavaScript</em> source <tt>235.bin</tt> using any text editor. Locate function:
<pre><code class="javascript">function ParseDoc(doc)
    {
        var aRules = GatherRulesFromDoc(doc);
        collSelectors = parser.Parse(aRules);

        // Set quirks mode if necessary
        if("BackCompat" == doc.compatMode)
        {
            for(var i = 0; i &lt; collSelectors.Count; i++)
            {
                <font color="#ff0000">collSelectors.item(i).SetQuirksMode(true);</font>
            }
        }

    }</code></pre>
<p>Change red marked line into:</p>
<pre><code class="javascript">                try { collSelectors.item(i).SetQuirksMode(true); } catch(e) {}</code></pre>
</li>
<li>Save back the resource file <tt>235.bin</tt> into <tt>TXT/235/1033</tt> of <tt>IEDevToolbar.dll</tt>. I used &#8220;replace&#8221; function of <a href="http://www.angusj.com/resourcehacker/">Resource Hacker</a>.</li>
</ol>
<p>Now you should have fixed <tt>IEDevToolbar.dll</tt>, that is not raising any errors anymore.</p>
<h3>Note</h3>
<p>Please don&#8217;t ask me about any binaries as it is against EULA of <em>IE Dev Toolbar</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/tweaks/ie-dev-toolbar-annoying-popup-fix/feed</wfw:commentRss>
		</item>
		<item>
		<title>jabberd2 win32 in the official repository</title>
		<link>http://www.nanoant.com/projects/jabberd2-win32-in-the-official-repository</link>
		<comments>http://www.nanoant.com/projects/jabberd2-win32-in-the-official-repository#comments</comments>
		<pubDate>Wed, 23 May 2007 14:29:32 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
		
		<category><![CDATA[Jabber]]></category>

		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.nanoant.com/projects/jabber/jabberd2-win32-in-the-official-repository</guid>
		<description><![CDATA[Thanks to Tomasz Sterna countryman of mine and current jabberd2 maintainer, win32 port is now in the official SVN repository. Project page was updated with new instructions. Now I&#8217;m thinking about the win32 installer.
I hope this will help to popularize XMPP somehow. I presume that free 3MB setup will be something that everyone can try [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/screenshots/jabberd2-win32/services.gif" title="jabberd2 services" alt="jabberd2 services" align="right" />Thanks to <a href="http://staff.xiaoka.com/smoku/">Tomasz Sterna</a> countryman of mine and current <a href="http://jabberd2.xiaoka.com/">jabberd2</a> maintainer, <a href="/projects/jabberd2-win32">win32 port</a> is now in the official SVN repository. <a href="/projects/jabberd2-win32">Project page</a> was updated with new instructions. Now I&#8217;m thinking about the win32 installer.</p>
<p>I hope this will help to popularize <a href="http://www.xmpp.org/">XMPP</a> somehow. I presume that free 3MB setup will be something that everyone can try installing at their office next to <em>MS Exchange</em> server, at least just to put e-mail/XMPP instead of just e-mail in the footer <img src='http://www.nanoant.com/wp/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> We just need to make Jabber trendy.. heh ?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nanoant.com/projects/jabberd2-win32-in-the-official-repository/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
