<?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>Google Stop Blog - The future is fusion &#187; C++</title>
	<atom:link href="http://googlestop.com/blog/tag/cpp/feed/" rel="self" type="application/rss+xml" />
	<link>http://googlestop.com/blog</link>
	<description>Just another weblog of Charry</description>
	<lastBuildDate>Sat, 10 Jul 2010 13:02:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>为什么不用SEH</title>
		<link>http://googlestop.com/blog/2007/07/%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%8d%e7%94%a8seh/</link>
		<comments>http://googlestop.com/blog/2007/07/%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%8d%e7%94%a8seh/#comments</comments>
		<pubDate>Tue, 17 Jul 2007 01:55:35 +0000</pubDate>
		<dc:creator>Charry</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[VC]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://googlestop.com/blog/2007/07/16/%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%8d%e7%94%a8seh/</guid>
		<description><![CDATA[前些时候，在论坛上看到一个朋友说SEH怎么怎么不好，一定不要用它。其实存在即合理。就像GOTO，不能因为它破坏了程序的流程，就不用它，适当的使用，还是可以事半功倍的。 大家知道SEH是Windows操作系统提供的一种异常处理机制，它和C++无关。在Compiler编译的时候，就把这个机制加入了我们的程序中。在VC下可以用__try, __finally, __except, __leave等关键字来标识。由于SEH可以捕获硬件异常(Hardware Exception)和软件异常(Software Exception)，它比C++的异常机制能捕获更多的异常，所以有朋友不喜欢这点，认为它掩盖了错误。其实这种说法是也是合情合理的，毕竟掩盖错误不是最好的解决方案，找出问题的所在才是我们应该做的。可是在现实中，我们不可能找到所有的bug，或者由于时间的关系，来不及修补这个bug，不如先用SEH挡一挡，何尝不可。 就像我之前的一个项目，程序在一个地方偶尔会Crash掉，而且这个地方如果不能正常执行丝毫不影响整个程序的运作，不会对用户造成损失，在找出问题真正的原因之前，我们完全可以用SEH捕获异常。  下面的例子也是一个SEH优势的体现 BOOL SafeDiv(INT32 dividend, INT32 divisor, INT32 *pResult) {     __try     {         *pResult = dividend / divisor;     }     __except(GetExceptionCode() == EXCEPTION_INT_DIVIDE_BY_ZERO ?              EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)     {         return FALSE;     }     return TRUE; } SafeDiv用来做除法操作，它的返回值指出函数是否执行成功。pResult指向最终的结果，如果不用SEH，这类Hardware Exception会导致程序Crash，这里引入了SEH，我们在发现有除零错误的时候，让函数返回FALSE，调用处通过检查函数的返回值就可以判断除法运算是否成功，没必要就因为一个除零错误导致程序Crash掉。 由于SEH是Windows操作系统特有的机制，所以它不适合用在那些跨平台的代码，这种情况不用也罢，既然SEH是一个Windows的一个很好的异常处理机制，我们虽不能滥用它，适当的、合理的使用还是值得推荐的。 P.S. For details [...]]]></description>
			<content:encoded><![CDATA[<p>前些时候，在论坛上看到一个朋友说SEH怎么怎么不好，一定不要用它。其实存在即合理。就像GOTO，不能因为它破坏了程序的流程，就不用它，适当的使用，还是可以事半功倍的。</p>
<p>大家知道SEH是Windows操作系统提供的一种异常处理机制，它和C++无关。在Compiler编译的时候，就把这个机制加入了我们的程序中。在VC下可以用__try, __finally, __except, __leave等关键字来标识。由于SEH可以捕获硬件异常(Hardware Exception)和软件异常(Software Exception)，它比C++的异常机制能捕获更多的异常，所以有朋友不喜欢这点，认为它掩盖了错误。其实这种说法是也是合情合理的，毕竟掩盖错误不是最好的解决方案，找出问题的所在才是我们应该做的。可是在现实中，我们不可能找到所有的bug，或者由于时间的关系，来不及修补这个bug，不如先用SEH挡一挡，何尝不可。</p>
<p>就像我之前的一个项目，程序在一个地方偶尔会Crash掉，而且这个地方如果不能正常执行丝毫不影响整个程序的运作，不会对用户造成损失，在找出问题真正的原因之前，我们完全可以用SEH捕获异常。</p>
<p> 下面的例子也是一个SEH优势的体现</p>
<p>BOOL SafeDiv(INT32 dividend, INT32 divisor, INT32 *pResult)<br />
{<br />
    __try<br />
    {<br />
        *pResult = dividend / divisor;<br />
    }<br />
    __except(GetExceptionCode() == EXCEPTION_INT_DIVIDE_BY_ZERO ?<br />
             EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)<br />
    {<br />
        return FALSE;<br />
    }<br />
    return TRUE;<br />
}</p>
<p>SafeDiv用来做除法操作，它的返回值指出函数是否执行成功。pResult指向最终的结果，如果不用SEH，这类Hardware Exception会导致程序Crash，这里引入了SEH，我们在发现有除零错误的时候，让函数返回FALSE，调用处通过检查函数的返回值就可以判断除法运算是否成功，没必要就因为一个除零错误导致程序Crash掉。</p>
<p>由于SEH是Windows操作系统特有的机制，所以它不适合用在那些跨平台的代码，这种情况不用也罢，既然SEH是一个Windows的一个很好的异常处理机制，我们虽不能滥用它，适当的、合理的使用还是值得推荐的。</p>
<p>P.S.<br />
For details about SEH, check this: <a href="http://www.google.com/search?hl=en&amp;q=Programming+Applications+for+Microsoft+Windows">http://www.google.com/search?hl=en&amp;q=Programming+Applications+for+Microsoft+Windows</a></p>
]]></content:encoded>
			<wfw:commentRss>http://googlestop.com/blog/2007/07/%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%8d%e7%94%a8seh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A New Release of Yet Another Browser</title>
		<link>http://googlestop.com/blog/2007/06/a-new-release-of-yet-another-browser/</link>
		<comments>http://googlestop.com/blog/2007/06/a-new-release-of-yet-another-browser/#comments</comments>
		<pubDate>Fri, 29 Jun 2007 03:17:39 +0000</pubDate>
		<dc:creator>Charry</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[My Application]]></category>

		<guid isPermaLink="false">http://googlestop.com/blog/2007/06/28/a-new-release-of-yet-another-browser/</guid>
		<description><![CDATA[I&#8217;ve changed my plan, Yet Another Browser(YAB for short) still looks like its sibling, if a brower has a MS-Word-like look-and-feel, is it weird? So far, I think YAB will be helpful for some guys. If you&#8217;re addicted to online photo communities, like Flickr, it can help you download photos when you go surfing, you don&#8217;t need to save the photos manually. Just one [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve changed my plan, Yet Another Browser(YAB for short) still looks like its sibling, if a brower has a MS-Word-like look-and-feel, is it weird? So far, I think YAB will be helpful for some guys. If you&#8217;re addicted to online photo communities, like <a href="http://www.flickr.com" target="_blank">Flickr</a>, it can help you download photos when you go surfing, you don&#8217;t need to save the photos manually. Just one click, all photos are flying to your disk on autopilot.</p>
<p>Features:</p>
<ol>
<li>You can tune up the opacity of main window</li>
<li>Multi-tab support</li>
<li>Right-click Close-Button to click all tabs, Left-Click just close one.</li>
<li>Your can rename the title of YAB, it will show what you want on task bar.</li>
<li>You can set the length of tab&#8217;s title.</li>
<li>Keep a list of websites you recently closed, you can easily undo it.</li>
<li>Just one-click to download all images in current tab</li>
<li>You can change the default direcotry where images will be saved.</li>
</ol>
<p>Todo:</p>
<ol>
<li>Boss key</li>
<li><span style="font-size: x-small;">Regular-Expressions for downloading images</span></li>
<li>Password Protection</li>
<li>Favorites</li>
<li>Clear hisotry</li>
<li>Clear dropdown list</li>
<li>Self-update</li>
<li>i18n</li>
<li>Auto-downloading images when you go surfing, even you don&#8217;t need one-click.</li>
<li>You can replace the icon of YAB with another one.</li>
</ol>
<p>Homepage for YAB: <a href="http://charry.org/m/myapps/YetAnotherBrowser">http://charry.org/m/myapps/YetAnotherBrowser</a> <br />
Stay tuned.</p>
]]></content:encoded>
			<wfw:commentRss>http://googlestop.com/blog/2007/06/a-new-release-of-yet-another-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TabIndex != TabPages.IndexOf</title>
		<link>http://googlestop.com/blog/2007/06/tabindex-tabpagesindexof/</link>
		<comments>http://googlestop.com/blog/2007/06/tabindex-tabpagesindexof/#comments</comments>
		<pubDate>Mon, 25 Jun 2007 11:17:39 +0000</pubDate>
		<dc:creator>Charry</dc:creator>
				<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://googlestop.com/blog/2007/06/25/tabindex-tabpagesindexof/</guid>
		<description><![CDATA[TabControl的有个属性叫TabIndex，每个从Control派生来的控件都有这个属性，这个Tab是Tab键的顺序（MSDN说：A control with a lower tab index receives focus before a control with a higher index.） 我正好需要获取TabControl中某个Tab Page的Index。这些Tab Page保存在TabControl的TabPages中，它是一个集合，实现了IList接口，其中有个方法就是IndexOf (Determines the index of a specific item in the IList.)。 鬼使神差的，我把TabIndex属性当成了Tab Page在TabPages中的Index了，花费了N久时间，才发现问题所在。Tab Index和IndexOf，TabPages，这几个词放在一起，一不小心就会搞错，错误总在不经意间。]]></description>
			<content:encoded><![CDATA[<p>TabControl的有个属性叫TabIndex，每个从Control派生来的控件都有这个属性，这个<strong>Tab</strong>是Tab键的顺序（MSDN说：A control with a lower tab index receives focus before a control with a higher index.）</p>
<p>我正好需要获取TabControl中某个Tab Page的Index。这些Tab Page保存在TabControl的TabPages中，它是一个集合，实现了IList接口，其中有个方法就是IndexOf (Determines the index of a specific item in the <strong>IList</strong>.)。</p>
<p>鬼使神差的，我把TabIndex属性当成了Tab Page在TabPages中的Index了，花费了N久时间，才发现问题所在。Tab Index和IndexOf，TabPages，这几个词放在一起，一不小心就会搞错，错误总在不经意间。</p>
]]></content:encoded>
			<wfw:commentRss>http://googlestop.com/blog/2007/06/tabindex-tabpagesindexof/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet Another Browser</title>
		<link>http://googlestop.com/blog/2007/06/yet-another-browser/</link>
		<comments>http://googlestop.com/blog/2007/06/yet-another-browser/#comments</comments>
		<pubDate>Thu, 14 Jun 2007 07:39:40 +0000</pubDate>
		<dc:creator>Charry</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[My Application]]></category>

		<guid isPermaLink="false">http://googlestop.com/blog/2007/06/14/yet-another-browser/</guid>
		<description><![CDATA[If you&#8217;re a office worker, are you afraid of being busted by your boss when surfing? I make this semi-browser from scratch, it resembles a regular Microsoft Office Suit Application,  I&#8217;ll add the following features to the browser, e.g.: Transparent window One-click to hide Download all images to your disk &#8230; I created it with [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a office worker, are you afraid of being busted by your boss when surfing? I make this semi-browser from scratch, it resembles a regular Microsoft Office Suit Application,  I&#8217;ll add the following features to the browser, e.g.:</p>
<ol>
<li>Transparent window</li>
<li>One-click to hide</li>
<li>Download all images to your disk</li>
<li>&#8230;</li>
</ol>
<p>I created it with C#,  it&#8217;s easy to create your own browser with its powerful components, everyone can make it if he wishes.</p>
<p><a href="http://www.googlestop.com/download/YetAnotherBrowser.exe">Download it!</a> (Make sure you have the .NET Framework 2.0 installed on your computer)</p>
]]></content:encoded>
			<wfw:commentRss>http://googlestop.com/blog/2007/06/yet-another-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
