<?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/"
	>

<channel>
	<title>Silicon Sparrow</title>
	<atom:link href="http://siliconsparrow.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://siliconsparrow.com</link>
	<description>Electronics and Software Design</description>
	<lastBuildDate>Fri, 03 Feb 2012 23:27:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>UI Horror Story of the Day</title>
		<link>http://siliconsparrow.com/ui-horror-story-of-the-day/</link>
		<comments>http://siliconsparrow.com/ui-horror-story-of-the-day/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 23:27:58 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=493</guid>
		<description><![CDATA[I finally got around to upgrading to Dev Studio 2010 Express. It looks nice so far but I don&#8217;t know whether to laugh or cry at the number of fundamental UI mistakes they have made with the documentation system. Have Microsoft learned nothing about user interface and user experience in the 18-odd years they have [...]]]></description>
			<content:encoded><![CDATA[<p>I finally got around to upgrading to Dev Studio 2010 Express. It looks nice so far but I don&#8217;t know whether to laugh or cry at the number of fundamental UI mistakes they have made with the documentation system. Have Microsoft learned nothing about user interface and user experience in the 18-odd years they have been developing Windows? I&#8217;d like to take this blog post to list some of the issues with this software.</p>
<p>Now in previous versions of Dev Studio, if you wanted to look up the manual for a key word or library function, you placed your cursor on the name and pressed F1. So wanting to know how to create a fixed array in C#, I typed the word &#8216;fixed&#8217; and pressed F1. Did I see the documentation? Nope.</p>
<p>What I did see was a dialog box asking whether I&#8217;d like to look up the documentation on my local machine or on the internet. I wish I&#8217;d taken a screen-shot of that dialog box because it was an absolute classic of bad design but I can&#8217;t make it appear again. Once I&#8217;d chosen, there was no way to go back to it and make a different choice.</p>
<p><strong>UI Lesson #1: Let the user go back. People make mistakes, if it is possible to undo, then allow it.</strong></p>
<p>&nbsp;</p>
<p>The choices on the dialog were &#8220;YES&#8221; or &#8220;NO&#8221;. Um, does that mean yes, look it up on the internet or no, don&#8217;t look it up on my local machine? Heads I win, tails you lose. Bad choice of wording for the buttons.</p>
<p><strong>UI Lesson #2: Label your dialog buttons with verbs &#8211; SAVE / DON&#8217;T SAVE is easier to understand than YES / NO</strong></p>
<p>&nbsp;</p>
<p>So I took a punt on NO which it turns out meant loading the documentation from the local machine. Well that&#8217;s OK, it should be faster loading locally right? But then again, should I care where it gets the documentation from as long as it gets it. Microsoft is interrupting my work flow. I just want to see the documentation, right now.</p>
<p><strong>UI Lesson #3: Don&#8217;t interrupt the user&#8217;s work flow unless you have a very good reason.</strong></p>
<p>&nbsp;</p>
<p>So next it goes about setting up a small web server on my PC so it can serve up the documentation in my browser. Takes a few seconds but that&#8217;s OK, except &#8211; get this &#8211; it doesn&#8217;t work! I get a 404 error! I did take a screenshot this time:</p>
<p style="text-align: center;"><img class="size-full wp-image-494 aligncenter" title="HelpFail" src="http://siliconsparrow.com/wp-content/uploads/2012/02/HelpFail.png" alt="" width="506" height="130" /></p>
<p>&nbsp;</p>
<p>So what this is telling me is that <strong>there is no local help! </strong>And the software was too brain-dead to realise it.</p>
<p><strong>UI Lessage #4: If you can automatically check something, don&#8217;t make the user manually check it!</strong></p>
<p>&nbsp;</p>
<p>There is no way I am going to spend time installing the local help on my PC. Remember what I want to do is view the help, not dink around with my computer all afternoon. So of course I now choose to look for the help online. So I click the link and&#8230;</p>
<p style="text-align: center;"><img class="size-full wp-image-495 aligncenter" title="HelpFail2" src="http://siliconsparrow.com/wp-content/uploads/2012/02/HelpFail2.png" alt="" width="484" height="331" /></p>
<p>&nbsp;</p>
<p><strong>UI Lesson #5: Honestly, just think!</strong></p>
<p>&nbsp;</p>
<p>I cannot believe how utterly broken this is. I think I&#8217;ll go look up my keyword on Google.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/ui-horror-story-of-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Incompatible Objective-C types initializing struct</title>
		<link>http://siliconsparrow.com/incompatible-objective-c-types-initializing-struct/</link>
		<comments>http://siliconsparrow.com/incompatible-objective-c-types-initializing-struct/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 01:57:28 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=489</guid>
		<description><![CDATA[This bizarre error message had me tearing my hair out this morning. I&#8217;ve finally figured it out. Here&#8217;s the scene: You have two classes, each class has an init method with the same name and taking the same parameters. Here&#8217;s an example: @interface myClass1 : NSObject { } -(myClass1 *)initWithName:(NSString *)name; @end @interface myClass2 : [...]]]></description>
			<content:encoded><![CDATA[<p>This bizarre error message had me tearing my hair out this morning. I&#8217;ve finally figured it out.</p>
<p>Here&#8217;s the scene: You have two classes, each class has an init method with the same name and taking the same parameters. Here&#8217;s an example:</p>
<pre>@interface myClass1 : NSObject { }

-(myClass1 *)initWithName:(NSString *)name;

@end

@interface myClass2 : NSObject { }

-(myClass2 *)initWithName:(NSString *)name;

@end</pre>
<p>Now try to initialize an instance of the first class:</p>
<pre>myClass1 *c = [[myClass1 alloc] initWithName:@"Fred"];</pre>
<p>You get <em>Incompatible Objective-C types initializing &#8216;struct myClass2 *&#8217;, expected &#8216;struct myClass1 *&#8217;</em> which doesn&#8217;t make any sense because the initializer never even mentions myClass2.</p>
<p>The thing is that the program will run fine, it just gives this warning at compile-time because the compiler can&#8217;t tell the difference between two different methods with the same signature. I like my code to compile with no errors and no warnings because I&#8217;m very fussy and thorough with my work. So even though this warning could be safely ignored, it still bugs me and I have to get rid of it!</p>
<p>So to shut the compiler up, I need to cast the object so it explicitly knows which method to call.</p>
<pre>myClass1 *c = [(myClass1 *)[myClass1 alloc] initWithName:@"Fred"];</pre>
<p>Casting always looks ugly to me but that&#8217;s the way around it.</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/incompatible-objective-c-types-initializing-struct/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NMEA Checksum Calculator</title>
		<link>http://siliconsparrow.com/nmea-checksum-calculator/</link>
		<comments>http://siliconsparrow.com/nmea-checksum-calculator/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 06:49:08 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=480</guid>
		<description><![CDATA[I&#8217;ve been doing a lot of GPS work lately. Here&#8217;s a little utility I wrote which I&#8217;d like to share with you all. It&#8217;s an NMEA checksum calculator written in PHP. Try it out here: http://siliconsparrow.com/nmeachecksum.php Here&#8217;s the source code: &#60;html&#62; &#60;head&#62; &#60;title&#62;NMEA Checksum Calculator&#60;/title&#62; &#60;/head&#62; &#60;body&#62; &#60;h1&#62;NMEA Checksum Calculator&#60;/h1&#62; &#60;?php // Simple NMEA Checksum [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of GPS work lately. Here&#8217;s a little utility I wrote which I&#8217;d like to share with you all. It&#8217;s an NMEA checksum calculator written in PHP.</p>
<p>Try it out here: <a href="http://siliconsparrow.com/nmeachecksum.php">http://siliconsparrow.com/nmeachecksum.php</a></p>
<p>Here&#8217;s the source code:</p>
<pre>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;NMEA Checksum Calculator&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;NMEA Checksum Calculator&lt;/h1&gt;
&lt;?php
// Simple NMEA Checksum calculator by Adam Pierce &lt;adam@siliconsparrow.com&gt;
// Created 12-Jan-2012.
// This code is public domain. Copy &amp; share it all you like for any purpose.

	if(array_key_exists('nmea',$_REQUEST))
	{
		$nmea = $_REQUEST['nmea'];
		print "&lt;p&gt;Calculating checksum for: ".htmlspecialchars($nmea)."&lt;/p&gt;\r\n";

		$checksum = 0;
		for($i = 0; $i &lt; strlen($nmea); $i++)
		{
			$c = substr($nmea,$i,1);
			$n = ord($c);
			if($c == '$')
				$checksum = 0;
			else if($c == '*')
				break;
			else
				$checksum ^= $n;
		}
		print "&lt;p&gt;Checksum is ".dechex($checksum)."&lt;/p&gt;\r\n";
	}
?&gt;
&lt;form action="nmeachecksum.php"&gt;
&lt;p&gt;Enter an NMEA String: &lt;input name="nmea" size="100" /&gt;
&lt;input type="submit" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/nmea-checksum-calculator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replicating ASCII Database to UTF-8 in PostgreSQL</title>
		<link>http://siliconsparrow.com/replicating-ascii-database-to-utf-8-in-postgresql/</link>
		<comments>http://siliconsparrow.com/replicating-ascii-database-to-utf-8-in-postgresql/#comments</comments>
		<pubDate>Mon, 28 Nov 2011 23:33:20 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=470</guid>
		<description><![CDATA[Well here&#8217;s a curly issue I blundered into today. I was trying to replicate a Postgres database from an old server to a new one using pg_dump/pg_restore and found some errors like this: invalid byte sequence for encoding "UTF8": 0x92 After some investigation it turns out the older version of Postgres defaults to ASCII encoding [...]]]></description>
			<content:encoded><![CDATA[<p>Well here&#8217;s a curly issue I blundered into today. I was trying to replicate a Postgres database from an old server to a new one using pg_dump/pg_restore and found some errors like this:</p>
<pre>invalid byte sequence for encoding "UTF8": 0x92</pre>
<p>After some investigation it turns out the older version of Postgres defaults to ASCII encoding of the data wheras the new version of Postgres defaults to UTF-8. Of course I would much prefer to use UTF-8 but shouldn&#8217;t those two encodings be compatible anyway? UTF-8 is supposed to be backward-compatible with ASCII.</p>
<p>What happened is a few non-ASCII characters got into the database. 0&#215;92 is not a valid ASCII code. It is a code from Latin-1 encoding. This was in the database thanks to my business partner who was entering some crap into the database using a Macintosh which wasn&#8217;t following the ASCII standard so much.</p>
<p>So how to solve it?</p>
<p>First I did a plain-text export of the database on the old server</p>
<pre>pg_dump -Fp my_database &gt; mydatabase.sql</pre>
<p>Then I converted the encoding to UTF-8</p>
<pre>iconv -f 8859_1 -t UTF-8 mydatabase.sql&gt; mydatabase.utf8.sql</pre>
<p>Finally I imported the converted data into the database on the new server</p>
<pre>createdb my_database
psql my_database -f mydatabase.utf8.sql</pre>
<p>And then I wrote a blog post so I&#8217;d remember all this next time the issue comes up.</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/replicating-ascii-database-to-utf-8-in-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smallest Computer Ever!</title>
		<link>http://siliconsparrow.com/smallest-computer-ever/</link>
		<comments>http://siliconsparrow.com/smallest-computer-ever/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 10:30:45 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=454</guid>
		<description><![CDATA[&#160; OK, so it&#8217;s not the smallest computer ever, but at only 3mm long it is the smallest computer I&#8217;ve ever programmed. This is the PIC10F206 and yes, that&#8217;s the tip of my finger it is sitting on. This little beastie has less than 1k of memory and only runs about as fast as an [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p><img class="alignright size-full wp-image-457" title="Tiny Computer" src="http://siliconsparrow.com/wp-content/uploads/2011/11/TinyComputer1.jpg" alt="" width="240" height="271" />OK, so it&#8217;s not the smallest computer ever, but at only 3mm long it is the smallest computer I&#8217;ve ever programmed. This is the <strong><a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en020032">PIC10F206</a></strong> and yes, that&#8217;s the tip of my finger it is sitting on.</p>
<p>This little beastie has less than 1k of memory and only runs about as fast as an <a href="http://en.wikipedia.org/wiki/Atari_ST">Atari ST</a> but hey, it&#8217;s a real honest-to-god computer and if you only want something simple done, it can be real useful. Oh, and it only costs 70 cents, way cheaper than the Atari.</p>
<p>So what did I use it for I hear you ask? well, I just needed a 40kHz oscillator with some low frequency modulation. You could probably do that with a couple of CMOS chips and a ceramic resonator but this solution is cheaper, smaller, uses no external components and I even have a couple of spare I/Os left over to, I don&#8217;t know, flash a light or something.</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/smallest-computer-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Class D Amplifier</title>
		<link>http://siliconsparrow.com/class-d-amplifier/</link>
		<comments>http://siliconsparrow.com/class-d-amplifier/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 12:13:10 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=449</guid>
		<description><![CDATA[I have been building audio amplifiers for one of my clients for a while now but we&#8217;ve been having some overheating issues so I decided to go high-tech, ditch the old-school linear amp and use a class-D amp. A class-D amp works a little differently from a traditional analogue amp in that it generates a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://siliconsparrow.com/wp-content/uploads/2011/11/VB3Prototype.jpg"><img class="alignright size-full wp-image-450" title="VB3Prototype" src="http://siliconsparrow.com/wp-content/uploads/2011/11/VB3Prototype.jpg" alt="" width="640" height="382" /></a>I have been building audio amplifiers for one of my clients for a while now but we&#8217;ve been having some overheating issues so I decided to go high-tech, ditch the old-school linear amp and use a class-D amp.</p>
<p>A class-D amp works a little differently from a traditional analogue amp in that it generates a high-frequency square wave which is pulse-width-modulated. This square wave is then put through a low-pass filter to knock the corners off it and you end up with a wave the same shape as the input wave. This is very clever because a transistor is most efficient when it is either fully off or fully on. By avoiding the linear analogue section of the transistor&#8217;s range, the power efficiency is very much improved.</p>
<p>After some research I decided to use the TPA3113 from Texas Instruments. I wired this thing up according to the recommended application circuit and it works pretty well. TI claim this device has a power efficiency of 87% and no heatsink is required. I have yet to properly load-test it but my initial tests are very promising.</p>
<p>The only drawback with this part is it&#8217;s sensitivity to power supply noise. A little ripple in the input voltage can make for some very nasty buzzing noises so I&#8217;m going to have to add some DC filtering.</p>
<p>This picture is of the whole board. The chip on the right is the class-D amp, the other chips are&#8230; well, I haven&#8217;t got it all working yet so I&#8217;ll leave that for a future blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/class-d-amplifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Count the words in a string using Postgres</title>
		<link>http://siliconsparrow.com/number-of-words-in-string-using-postgres/</link>
		<comments>http://siliconsparrow.com/number-of-words-in-string-using-postgres/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 11:37:54 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=442</guid>
		<description><![CDATA[I just wanted to post this little bit of code. I needed to produce a list of phrases from a database but only show phrases with more than four words. Here&#8217;s the SQL: select phrasetext from phrases where array_upper(regexp_split_to_array(phrasetext,E'\\s+'),1) &#62; 4; How this works is a regular expression is used to split the string by [...]]]></description>
			<content:encoded><![CDATA[<p>I just wanted to post this little bit of code. I needed to produce a list of phrases from a database but only show phrases with more than four words. Here&#8217;s the SQL:</p>
<pre>select phrasetext from phrases
where array_upper(regexp_split_to_array(phrasetext,E'\\s+'),1) &gt; 4;</pre>
<p>How this works is a regular expression is used to split the string by spaces. This spits out a text array. The array_upper function retrieves the largest index in the array which, being 1-based is the same as the number of items in the array &#8211; which of course is the same as the number of words in the phrase.</p>
<p><strong>UPDATE:</strong> I found a simpler way to do this, just use the spaces &#038; wildcards:</p>
<pre>select phrasetext from phrases
where phrasetext like '% % % %';</pre>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/number-of-words-in-string-using-postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First adventures with iPhone programming</title>
		<link>http://siliconsparrow.com/first-adventures-with-iphone-programming/</link>
		<comments>http://siliconsparrow.com/first-adventures-with-iphone-programming/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 12:16:23 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=419</guid>
		<description><![CDATA[The last month or so I have been learning how to write apps for iPhone because I have a business opportunity for an iPhone app (which I can&#8217;t tell you about yet &#8211; stay tuned). But this article is not about the app, it is about my first impressions of programming for iPhone after 20+ [...]]]></description>
			<content:encoded><![CDATA[<p>The last month or so I have been learning how to write apps for iPhone because I have a business opportunity for an iPhone app (which I can&#8217;t tell you about yet &#8211; stay tuned).</p>
<p>But this article is not about the app, it is about my first impressions of programming for iPhone after 20+ years of programming for Windows and UNIX. I have never even written anything for a Mac in all that time.</p>
<p>Coming from the world of C++, Java and C#, I am finding the Objective-C language rather alien. It&#8217;s like a bunch of LISP programmers took a look at C and tried to make it more like the One Pure Language. The result is like a bastard offspring of C and Smalltalk.</p>
<p>And it&#8217;s so wordy! To show what I mean, here&#8217;s an example of some code written in C++. This just manages the storage of a person&#8217;s name and can concatenate the first and last names.</p>
<pre>using namespace std;
class Person
{
public:
// Storage.
 string _first;
 string _last;

// Constructor
 Person(const char *firstname, const char *lastname)
  : _first(firstname)
  , _last(lastname)
 { }

// Concatenate the first and last names into a full name.
 string toString() const
 {
   ostringstream oss;
   oss << _first << " " << _last;
   return oss.str();
 }
};
</pre>
<p>Now I would have thought that C++ code has a lot of lines to do a fairly simple task but look at the Objective-C equivalent:</p>
<pre>@interface Person : NSObject
{
// Storage.
  NSString *first;
  NSString *last;
}

@property (retain) NSString *first;
@property (retain) NSString *last;

- (Person *)initWithName:(NSString *)ifirst withLastName:(NSString *)ilast;
- (NSString *)toString;

@end

@implementation Person

@synthesize first;
@synthesize last;

// Constructor.
- (Person *)initWithName:(NSString *)ifirst withLastName:(NSString *)ilast
{
  [super init];
  if(self)
  {
    self.first = ifirst;
    self.last = ilast;
  }
  return self;
}

// Destructor.
- (void) dealloc
{
   [first release];
   [last release];
   [super dealloc];
}

// Concatenate the first and last names into a full name.
- (NSString *)toString
{
  return [NSString stringWithFormat:@"%@ %@",self.first,self.last];
}

@end</pre>
<p>The Objective-C requires many more lines of code to do the same job. You may say "so what?" but more lines means more time taken to write it and more places for errors to occur.</p>
<p>Also note that the C++ constructor is much simpler and I did not need to write a destructor at all for such a simple class. C++ is a very old language now, modern languages such as Python and C# do not require you to even <strong>think</strong> about destructors, they just manage the memory completely automatically. Having to care about allocating and freeing memory is kind of like stepping back into the 1990s.</p>
<p>The only place where the Objective-C was more elegant than C++ was the toString function where it could be implemented in just one line in Objective-C vs. 3 lines in C++.</p>
<p>But all grizzling aside, I would now call myself reasonably proficient at iPhone programming and am finding the API fairly easy to work with. My app is almost finished and I hope to have it in the App Store soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/first-adventures-with-iphone-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Solved &#8211; CDHtmlDialog and bitmap resources</title>
		<link>http://siliconsparrow.com/solved-cdhtmldialog-and-bitmap-resources/</link>
		<comments>http://siliconsparrow.com/solved-cdhtmldialog-and-bitmap-resources/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 03:06:58 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=413</guid>
		<description><![CDATA[Today I am working on some old code and am being frustrated by the CDHtmlDialog class in MFC7. All I want to do is display some hyperlinks and a BMP image embedded in the EXE as a resource &#8211; is that so very hard? Well it can be done but it&#8217;s not well documented. Here [...]]]></description>
			<content:encoded><![CDATA[<p>Today I am working on some old code and am being frustrated by the CDHtmlDialog class in MFC7. All I want to do is display some hyperlinks and a BMP image embedded in the EXE as a resource &#8211; is that so very hard? Well it can be done but it&#8217;s not well documented. Here is my solution which I worked out from hours of reading MSDN, forums and some guesswork.</p>
<pre>&lt;img src="res://MyApp.exe/#2/#101" /&gt;</pre>
<p>So now to explain. First use the res:// protocol so that it knows you want to load from a resource. The 2nd item is MyApp.exe and is simply the name of your executable, you don&#8217;t have to give a full path.</p>
<p>Now the bit that isn&#8217;t obvious. The #2 is the resource type. #2 is for bitmap resources. If you have another type of resource, you&#8217;d need a different number. I have no idea how to find out the number for other types, it doesn&#8217;t seem to be explained anywhere in MSDN.</p>
<p>Finally the #101 is the resource ID for the bitmap. To find this in MFC you need to look at the file Resources.h, find the bitmap you are looking for and note down it&#8217;s resource ID number.</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/solved-cdhtmldialog-and-bitmap-resources/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dead Easy Pure CSS Button Class</title>
		<link>http://siliconsparrow.com/dead-easy-pure-css-button-class/</link>
		<comments>http://siliconsparrow.com/dead-easy-pure-css-button-class/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 23:44:38 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://siliconsparrow.com/?p=402</guid>
		<description><![CDATA[Here&#8217;s a really simple way to make a styled button using only CSS. I wrote this because a lot of the &#8220;Pure CSS Button&#8221; scripts I found on the interwebs use a PNG image for the button which is not pure enough for me dammit! This one does not use any image at all which [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a really simple way to make a styled button using only CSS. I wrote this because a lot of the &#8220;Pure CSS Button&#8221; scripts I found on the interwebs use a PNG image for the button which is not pure enough for me dammit!</p>
<p>This one does not use any image at all which is good for saving space if you are, say, working on an embedded web server with only a few kB of storage. It is also quick to set up. Simply cut &amp; paste the following lines into your CSS file and add <strong>class=&#8221;button&#8221;</strong> to your tag in the HTML.</p>
<pre>.button {
	font-size: smaller;
	background: #CCCCCC;
	padding: 3px;
	border-top: 1px solid #EEEEEE;
	border-left: 1px solid #EEEEEE;
	border-right: 1px solid #666666;
	border-bottom: 1px solid #666666;
	text-decoration: none;
}

.button:active {
	border-top: 1px solid #666666;
	border-left: 1px solid #666666;
	border-right: 1px solid #EEEEEE;
	border-bottom: 1px solid #EEEEEE;
}</pre>
<p>And here is an example of a link using this style:</p>
<pre>&lt;a class="button" href="otherpage.html"&gt;Go to Other Page&lt;/a&gt;</pre>
<style>
.button2 {
	font-size: smaller;
	background: #CCCCCC;
	color: black;
	padding: 3px;
	border-top: 1px solid #EEEEEE;
	border-left: 1px solid #EEEEEE;
	border-right: 1px solid #666666;
	border-bottom: 1px solid #666666;
	text-decoration: none;
}
.button2:active {
	border-top: 1px solid #666666;
	border-left: 1px solid #666666;
	border-right: 1px solid #EEEEEE;
	border-bottom: 1px solid #EEEEEE;
}
</style>
<p>Here is what it looks like: <a class="button2" href="#">Test Button</a> &#8211; how easy was that!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://siliconsparrow.com/dead-easy-pure-css-button-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

