<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>majkel</title>
	<atom:link href="http://majkel.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://majkel.wordpress.com</link>
	<description>adventures in programming</description>
	<lastBuildDate>Sun, 28 Jun 2009 14:40:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='majkel.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>majkel</title>
		<link>http://majkel.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://majkel.wordpress.com/osd.xml" title="majkel" />
	<atom:link rel='hub' href='http://majkel.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Getting a GDI+ Bitmap from an HICON with proper transparency</title>
		<link>http://majkel.wordpress.com/2008/02/29/getting-a-gdi-bitmap-from-an-hicon-with-proper-transparency/</link>
		<comments>http://majkel.wordpress.com/2008/02/29/getting-a-gdi-bitmap-from-an-hicon-with-proper-transparency/#comments</comments>
		<pubDate>Fri, 29 Feb 2008 18:46:55 +0000</pubDate>
		<dc:creator>mikejurka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://majkel.wordpress.com/?p=10</guid>
		<description><![CDATA[The GDI+ Bitmap class has a nice constructor that takes in a HICON. The problem is that it doesn&#8217;t preserve alpha values&#8211; icons such as the Firefox icon that have semi-transparent shadows show up with completely black shadows. This code will get you the icon with proper transparency: Gdiplus::Bitmap *WindowsSystem::GetIconPixelData(HICON hIcon) { ICONINFO iconInfo; GetIconInfo(hIcon, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=10&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The GDI+ Bitmap class has a nice constructor that takes in a HICON. The problem is that it doesn&#8217;t preserve alpha values&#8211; icons such as the Firefox icon that have semi-transparent shadows show up with completely black shadows. This code will get you the icon with proper transparency:</p>
<pre>
Gdiplus::Bitmap *WindowsSystem::GetIconPixelData(HICON hIcon)
{
	ICONINFO iconInfo;
	GetIconInfo(hIcon, &amp;iconInfo);

	BITMAP iconBmp;
	GetObject(iconInfo.hbmColor, sizeof(BITMAP),&amp;iconBmp);

	Gdiplus::Bitmap* bitmap = new Gdiplus::Bitmap(iconBmp.bmWidth,iconBmp.bmHeight,PixelFormat32bppARGB);

	bool hasAlpha = false;
	{
		// We have to read the raw pixels of the bitmap to get proper transparency information
		// (not sure why, all we're doing is copying one bitmap into another)

		Gdiplus::Bitmap colorBitmap(iconInfo.hbmColor, NULL);
		Gdiplus::BitmapData bmpData;
		Gdiplus::Rect bmBounds(0, 0, colorBitmap.GetWidth(), colorBitmap.GetHeight());

		colorBitmap.LockBits(&amp;bmBounds, Gdiplus::ImageLockModeRead, colorBitmap.GetPixelFormat(), &amp;bmpData);
		for (int y = 0; y &lt; colorBitmap.GetHeight(); y++)
		{
			byte *pixelBytes = (byte*)bmpData.Scan0 + y*bmpData.Stride;

			for (int x = 0; x SetPixel(x, y, Gdiplus::Color(*pixel));
				hasAlpha = hasAlpha || (pixelBytes[3] &gt; 0 &amp;&amp; pixelBytes[3] &lt; 255);
			}
		}
		colorBitmap.UnlockBits(&amp;bmpData);
	}

	if (!hasAlpha)
	{
		// If there's no alpha transparency information, we need to use the mask
		// to turn back on visible pixels

		Gdiplus::Bitmap maskBitmap(iconInfo.hbmMask,NULL);
		Gdiplus::Color cMask, cBitmap;
		for (int y = 0; y &lt; maskBitmap.GetHeight(); y++)
		{
			for (int x = 0; x GetPixel(x, y, &amp;cBitmap);
					cBitmap.SetValue(cBitmap.GetValue() | 0xFF000000); // turn alpha to opaque (i.e. 0xFF)
					bitmap-&gt;SetPixel(x, y, cBitmap);
				}
			}
		}

	}

	return bitmap ;

}
</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/majkel.wordpress.com/10/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/majkel.wordpress.com/10/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/majkel.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/majkel.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/majkel.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/majkel.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/majkel.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/majkel.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/majkel.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/majkel.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/majkel.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/majkel.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/majkel.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/majkel.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/majkel.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/majkel.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=10&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://majkel.wordpress.com/2008/02/29/getting-a-gdi-bitmap-from-an-hicon-with-proper-transparency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/97d2bd38930d3b030a3b1410ea42dbfb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mikejurka</media:title>
		</media:content>
	</item>
		<item>
		<title>Getting events on WPF Canvas background</title>
		<link>http://majkel.wordpress.com/2007/10/30/getting-events-on-wpf-canvas-background/</link>
		<comments>http://majkel.wordpress.com/2007/10/30/getting-events-on-wpf-canvas-background/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 22:11:07 +0000</pubDate>
		<dc:creator>mikejurka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://majkel.wordpress.com/2007/10/30/getting-events-on-wpf-canvas-background/</guid>
		<description><![CDATA[I recently encountered an error where I was not getting MouseMove events for a Canvas that was within a StackPanel. The first problem is that, if the background is not set to anything, there will be no events transmitted. A simple solution is just to set the background to transparent or white (or whatever color [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=9&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently encountered an error where I was not getting MouseMove events for a Canvas that was within a StackPanel.</p>
<p>The first problem is that, if the background is not set to anything, there will be no events transmitted. A simple solution is just to set the background to transparent or white (or whatever color you want).</p>
<p>The second problem, which took me forever to figure out, stems from the fact that the Canvas width was 1 pixel (or was it 0?) once I put it into my StackPanel. However, this does not keep elements in the Canvas from appearing outside this 1-pixel wide region, so it appears as if the width of the Canvas is greater. So the important thing to realize is that the Canvas will only respond to events that are within the area covered by its width/height.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/majkel.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/majkel.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/majkel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/majkel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/majkel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/majkel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/majkel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/majkel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/majkel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/majkel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/majkel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/majkel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/majkel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/majkel.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/majkel.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/majkel.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=9&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://majkel.wordpress.com/2007/10/30/getting-events-on-wpf-canvas-background/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/97d2bd38930d3b030a3b1410ea42dbfb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mikejurka</media:title>
		</media:content>
	</item>
		<item>
		<title>Windows XP using 100% CPU in Boot Camp</title>
		<link>http://majkel.wordpress.com/2007/10/18/windows-xp-using-100-cpu-in-boot-camp/</link>
		<comments>http://majkel.wordpress.com/2007/10/18/windows-xp-using-100-cpu-in-boot-camp/#comments</comments>
		<pubDate>Thu, 18 Oct 2007 01:58:59 +0000</pubDate>
		<dc:creator>mikejurka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://majkel.wordpress.com/2007/10/18/windows-xp-using-100-cpu-in-boot-camp/</guid>
		<description><![CDATA[I&#8217;ve had this problem several times where my Windows XP installed on a Boot Camp partition on my Macbook will suddenly freak out and start using 100% CPU and generally being very unresponsive. Thanks a tip from a friend I found a very easy fix: reboot into MacOS, and then boot into Windows XP again. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=8&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had this problem several times where my Windows XP installed on a Boot Camp partition on my Macbook will suddenly freak out and start using 100% CPU and generally being very unresponsive. Thanks a tip from a friend I found a very easy fix: reboot into MacOS, and then boot into Windows XP again.</p>
<p>It seems that <a href="http://forums.macnn.com/104/alternative-operating-systems/329302/macbook-cpu-100-issues-power-xp/">other people</a> have the <a href="http://discussions.apple.com/thread.jspa?messageID=4561647">same problem</a> as well.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/majkel.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/majkel.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/majkel.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/majkel.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/majkel.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/majkel.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/majkel.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/majkel.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/majkel.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/majkel.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/majkel.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/majkel.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/majkel.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/majkel.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/majkel.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/majkel.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=8&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://majkel.wordpress.com/2007/10/18/windows-xp-using-100-cpu-in-boot-camp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/97d2bd38930d3b030a3b1410ea42dbfb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mikejurka</media:title>
		</media:content>
	</item>
		<item>
		<title>Modifying your Child&#8217;s transform in WPF without changing its RenderTransform or LayoutTransform</title>
		<link>http://majkel.wordpress.com/2007/10/06/modifying-your-childs-transform-in-wpf-without-changing-its-rendertransform-or-layouttransform/</link>
		<comments>http://majkel.wordpress.com/2007/10/06/modifying-your-childs-transform-in-wpf-without-changing-its-rendertransform-or-layouttransform/#comments</comments>
		<pubDate>Sat, 06 Oct 2007 15:33:27 +0000</pubDate>
		<dc:creator>mikejurka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://majkel.wordpress.com/2007/10/06/modifying-your-childs-transform-in-wpf-without-changing-its-rendertransform-or-layouttransform/</guid>
		<description><![CDATA[Sometimes in WPF you might want to create a class that has a Child and that somehow changes the presentation of the Child, perhaps by scaling it or translating it. And example is the Viewbox class, which scales your content to fit the window. You could do this just by modifying the RenderTransform or LayoutTransform [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=7&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes in WPF you might want to create a class that has a Child and that somehow changes the presentation of the Child, perhaps by scaling it or translating it. And example is the Viewbox class, which scales your content to fit the window. You could do this just by modifying the RenderTransform or LayoutTransform of the Child. However, if you  want this be a general, reusable class, you probably shouldn&#8217;t touching those properties of your Child, in case someone else might want to.</p>
<p>The solution is to add another node in the hierarchy, so you have:</p>
<blockquote><p>(your custom class) &#8211;&gt; (a private container class) &#8211;&gt; Child</p></blockquote>
<p>Then, you could just modify the container class&#8217;s transforms, and it would affect the presentation of the Child. I coded up a trivial example which scales everything 2x:</p>
<pre>
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace Model
{
    class ZoomAndPan : Decorator
    {
        Decorator _container;

        public ZoomAndPan()
        {
            _container = new Decorator();
            AddVisualChild(_container);
            AddLogicalChild(_container);

            _container.RenderTransform = new RotateTransform(45);
        }

        public override UIElement Child
        {
            get { return _container.Child; }
            set { _container.Child = value; }
        }

        protected override int VisualChildrenCount
        {
            get { return _container != null ? 1 : 0; }
        }

        protected override Visual GetVisualChild(int index)
        {
            if (index &gt; 0 || _container == null)
                throw new ArgumentOutOfRangeException("index");

            return _container;
        }

        protected override Size MeasureOverride(Size sizeAvailable)
        {
            _container.Measure(sizeAvailable);
            return _container.DesiredSize;
        }

        protected override Size ArrangeOverride(Size sizeArrange)
        {
            _container.Arrange(new Rect(new Point(0, 0), sizeArrange));
            return sizeArrange;
        }

        [STAThread]
        static void Main(string[] args)
        {
            Rectangle r = new Rectangle();
            r.Fill = Brushes.Bisque;
            r.Width = 200;
            r.Height = 200;

            Canvas canv = new Canvas();
            canv.Children.Add(r);

            ZoomAndPan zp = new ZoomAndPan();
            zp.Child = canv;

            Window w = new Window();
            w.Content = zp;

            new Application().Run(w);
        }
    }
}
</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/majkel.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/majkel.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/majkel.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/majkel.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/majkel.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/majkel.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/majkel.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/majkel.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/majkel.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/majkel.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/majkel.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/majkel.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/majkel.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/majkel.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/majkel.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/majkel.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=7&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://majkel.wordpress.com/2007/10/06/modifying-your-childs-transform-in-wpf-without-changing-its-rendertransform-or-layouttransform/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/97d2bd38930d3b030a3b1410ea42dbfb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mikejurka</media:title>
		</media:content>
	</item>
		<item>
		<title>Global keyboard and mouse hooks without the lag</title>
		<link>http://majkel.wordpress.com/2007/09/20/global-keyboard-and-mouse-hooks-without-the-lag/</link>
		<comments>http://majkel.wordpress.com/2007/09/20/global-keyboard-and-mouse-hooks-without-the-lag/#comments</comments>
		<pubDate>Thu, 20 Sep 2007 04:39:04 +0000</pubDate>
		<dc:creator>mikejurka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://majkel.wordpress.com/2007/09/20/global-keyboard-and-mouse-hooks-without-the-lag/</guid>
		<description><![CDATA[ Note (10/6/2007): I found a much better (and simpler) way of doing this. Details below. For the purposes of a project I was working on, I needed to detect when the user was pressing a key or moving the mouse. Because my project is all done in C#, I found this piece of code from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=6&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> <strong>Note (10/6/2007): I found a much better (and simpler) way of doing this. Details below. </strong></p>
<p>For the purposes of a project I was working on, I needed to detect when the user was pressing a key or moving the mouse. Because my project is all done in C#, I found this <a href="http://www.codeproject.com/csharp/globalhook.asp">piece of code from Code Project</a> very helpful. It&#8217;s just a drop-in class that notifies you whenever you receive a keystroke or mouse activity. All was great except for one thing: when you click on the minimize, maximize, or close buttons of your application, the whole application starts stuttering. Other applications running at the time are not affected, but this little problem plagues every implementation of global mouse hooks that I could find, whether written in managed or unmanaged code. Instead, I&#8217;m going to use a more roundabout method. I&#8217;ll have a very small Win32 app print basic information about events to the console, and then read this information in from my C# application. I found this <a href="http://www.gamedev.net/community/forums/topic.asp?topic_id=463478">great little C++ global hooking app</a> after a lot of looking.</p>
<p><strong>Addendum (10/6/2007):</strong></p>
<p>It turns out  a much simpler way is to set up the hook in a new thread. You simply create a new thread and call SetWindowsHookEx from that thread. However, if that is all you do you will not be receiving any events. You need to create a message loop in the thread that reads messages coming to it and processes them. Fortunately, this is very easy. Using WPF, all you need to do is call Dispatcher.Run() after you initialize the hook. Using Windows Forms, I think all you need to do is call Application.Run().</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/majkel.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/majkel.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/majkel.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/majkel.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/majkel.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/majkel.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/majkel.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/majkel.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/majkel.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/majkel.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/majkel.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/majkel.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/majkel.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/majkel.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/majkel.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/majkel.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=6&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://majkel.wordpress.com/2007/09/20/global-keyboard-and-mouse-hooks-without-the-lag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/97d2bd38930d3b030a3b1410ea42dbfb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mikejurka</media:title>
		</media:content>
	</item>
		<item>
		<title>&#8220;Unrecoverable build error&#8221; when building Setup project in Microsoft Visual Studio 2005</title>
		<link>http://majkel.wordpress.com/2007/08/08/unrecoverable-build-error-when-building-setup-project-in-vsnet-2005/</link>
		<comments>http://majkel.wordpress.com/2007/08/08/unrecoverable-build-error-when-building-setup-project-in-vsnet-2005/#comments</comments>
		<pubDate>Wed, 08 Aug 2007 21:22:35 +0000</pubDate>
		<dc:creator>mikejurka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://majkel.wordpress.com/2007/08/08/unrecoverable-build-error-when-building-setup-project-in-vsnet-2005/</guid>
		<description><![CDATA[I was having this problem and tried everything in this Microsoft knowledge base article. It was no help. Finally I tried the suggestion at the end of this forum and it worked! What an intuitive piece of software Visual Studio is&#8230;.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=5&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was having this problem and tried everything in <a href="http://support.microsoft.com/kb/329214">this Microsoft knowledge base article</a>. It was no help. Finally I tried the suggestion at the <a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=128028&amp;SiteID=1">end of this forum</a> and it worked! What an intuitive piece of software Visual Studio is&#8230;.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/majkel.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/majkel.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/majkel.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/majkel.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/majkel.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/majkel.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/majkel.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/majkel.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/majkel.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/majkel.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/majkel.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/majkel.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/majkel.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/majkel.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/majkel.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/majkel.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=5&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://majkel.wordpress.com/2007/08/08/unrecoverable-build-error-when-building-setup-project-in-vsnet-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/97d2bd38930d3b030a3b1410ea42dbfb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mikejurka</media:title>
		</media:content>
	</item>
		<item>
		<title>Using cairo, OpenGL, and C#</title>
		<link>http://majkel.wordpress.com/2007/04/26/using-cairo-opengl-and-c/</link>
		<comments>http://majkel.wordpress.com/2007/04/26/using-cairo-opengl-and-c/#comments</comments>
		<pubDate>Thu, 26 Apr 2007 09:26:36 +0000</pubDate>
		<dc:creator>mikejurka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Cairo]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://majkel.wordpress.com/2007/04/26/using-cairo-opengl-and-c/</guid>
		<description><![CDATA[I&#8217;m just starting to play with combining a vector-graphics library with OpenGL. I also wanted to take advantage of all the great features of C# and .NET, as well as using a solution that would port easily between Mac OS X, Windows, and Linux. In the end, I decided that using cairo for vector graphics [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=3&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m just starting to play with combining a vector-graphics library with OpenGL. I also wanted to take advantage of all the great features of C# and .NET, as well as using a solution that would port easily between Mac OS X, Windows, and Linux. In the end, I decided that using <a href="http://www.cairographics.org/">cairo </a>for vector graphics and the <a href="http://www.taoframework.com/">Tao Framework</a> for OpenGL was the way to go.</p>
<p>The Mono Project has C# bindings for cairo, but unfortunately the latest version still didn&#8217;t support everything I needed. I was fortunate, however, to come across cleaned-up cairo-sharp library at <a href="http://www.ndesk.org/">NDesk</a>. I took the latest snapshot, and because I don&#8217;t have make installed on my computer, I simply created a Microsoft Visual C# Express class library project, put all the files inside of it, and built the Mono.Cairo.dll assembly.</p>
<p>There were several links that were especially pertinent to what I was trying to do. Cairo has a guide to <a href="http://www.cairographics.org/OpenGL">using cairo and OpenGL</a>, and the Mono Project had some <a href="http://www.mono-project.com/Drawing">information about using the Mono.Cairo bindings</a>. Unfortunately, their links to more samples did not seem to work.</p>
<p>In the end, I was able to get a very simple example working. The steps are after the jump:</p>
<p><span id="more-3"></span></p>
<ol>
<li>If you haven&#8217;t already, <a href="http://www.taoframework.com/downloads">install the Tao Framework</a>.</li>
<li>Make a copy of the cleaned-up cairo-sharp (i.e. Mono.Cairo) library from <a href="http://www.ndesk.org/">NDesk</a>. You will also need the <a href="http://www.cairographics.org/download">cairo dlls</a>; in my case, they were already installed as part of Mono.</li>
<li>We will be modifying a Tao Framework / <a href="http://nehe.gamedev.net/">NeHe </a>sample project. Go to your Tao Framework installation, and go to the <strong>source\examples\NeHe</strong> directory.</li>
<li>Create a new C# Windows Application in Visual Studio and replace <em>all</em> the code in the file <strong>Program.cs </strong>with the text from the file <strong>Lesson06.cs</strong> in the Tao Framework NeHe samples directory.</li>
<li>Add a <strong>reference </strong>to the Tao Framework <strong>OpenGL Binding</strong> and <strong>Windows Platform API Binding.</strong> Add a reference to the Mono.Cairo assembly as well. Add the line &#8220;<code>using Cairo;</code>&#8221; at the top of the source file. A few classes will now be ambiguous when you recompile; fix them to use the standard class library (<em>not </em>Cairo).</li>
<li>Change the name of the method <code>Run </code>to <code>Main</code>. In case you&#8217;re curious, you can compile but the program will crash because it cannot find a texture that it tries to preload.</li>
<li>At the beginning of the <code>LoadGLTexture </code>method, add the following code (taken from the <a href="http://www.mono-project.com/Drawing">Mono website</a>). This code generates an in-memory bitmap for Cairo and draws something interesting on it.<br />
<blockquote><p><code> Cairo.ImageSurface i = new Cairo.ImageSurface(Format.Argb32, 256, 256);<br />
Cairo.Context gr = new Cairo.Context(i);</code></p>
<p><code>// Shape<br />
gr.MoveTo(new PointD(100, 200));<br />
gr.CurveTo(new PointD(100, 100), new PointD(100, 100),<br />
new PointD(200, 100));<br />
gr.CurveTo(new PointD(200, 200), new PointD(200, 200),<br />
new PointD(100, 200));<br />
gr.ClosePath();</code></p>
<p><code>// Save the state to restore it later. That will NOT save the path<br />
gr.Save();<br />
Cairo.Gradient pat = new Cairo.LinearGradient(100, 200, 200, 100);<br />
pat.AddColorStop(0, new Cairo.Color(0, 0, 0, 1));<br />
pat.AddColorStop(1, new Cairo.Color(1, 0, 0, 1));<br />
gr.SetSource(pat);</code></p>
<p><code>// Fill the path with pattern<br />
gr.FillPreserve();</code></p>
<p><code>// We "undo" the pattern setting here<br />
gr.Restore();</code></p>
<p><code>// Color for the stroke<br />
gr.SetSource(new Cairo.Color(0, 0, 0));</code></p>
<p><code>gr.LineWidth = 3;<br />
gr.Stroke();</code></p></blockquote>
</li>
<li>Remove the instantiation for <code>textureImage </code>and replace all references to <code>textureImage </code>with <code>i</code> (<code>i</code> is the Cairo bitmap). Completely remove the follow two lines:<br />
<blockquote><p><code>textureImage[0] = LoadBMP("NeHe.Lesson06.NeHe.bmp");                // Load The Bitmap<br />
BitmapData bitmapData = textureImage[0].LockBits(rectangle, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);</code></p></blockquote>
</li>
<li>The most important step. Previously the program was copying an imported file into a texture. Now we want to copy out Cairo bitmap instead. We replace this line:<br />
<code>Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB8, textureImage[0].Width, textureImage[0].Height, 0, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, bitmapData.Scan0);</code><br />
with this one:<br />
<code>Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB8, i.Width, i.Height, 0, Gl.GL_BGRA, Gl.GL_UNSIGNED_BYTE, i.Data);</code></li>
<li>At the end of the method, before we return, insert calls to dispose the <code>Context </code>and <code>ImageSurface </code>objects we created:<br />
<blockquote><p><code>((IDisposable)gr.Target).Dispose();<br />
((IDisposable)gr).Dispose();</code></p></blockquote>
</li>
<li>Voila! You have pretty vector graphics being mapped onto a cube.<br />
<a title="openglandcairo01.png" href="http://majkel.files.wordpress.com/2007/04/openglandcairo01.png"><img src="http://majkel.files.wordpress.com/2007/04/openglandcairo01.png?w=418" alt="openglandcairo01.png" /></a></li>
</ol>
<p>You can get the <a href="http://mikejurka.backpackit.com/attachments/0156/8048/original.zip/as/OpenGLandCairo01.zip">Microsoft Visual C# Express project</a> as well.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/majkel.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/majkel.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/majkel.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/majkel.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/majkel.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/majkel.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/majkel.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/majkel.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/majkel.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/majkel.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/majkel.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/majkel.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/majkel.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/majkel.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/majkel.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/majkel.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=majkel.wordpress.com&amp;blog=1028691&amp;post=3&amp;subd=majkel&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://majkel.wordpress.com/2007/04/26/using-cairo-opengl-and-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/97d2bd38930d3b030a3b1410ea42dbfb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mikejurka</media:title>
		</media:content>

		<media:content url="http://majkel.files.wordpress.com/2007/04/openglandcairo01.png" medium="image">
			<media:title type="html">openglandcairo01.png</media:title>
		</media:content>
	</item>
	</channel>
</rss>
