<?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>The Pursuit Of A Life &#187; WebBrowser</title>
	<atom:link href="http://thepursuitofalife.com/tag/webbrowser/feed/" rel="self" type="application/rss+xml" />
	<link>http://thepursuitofalife.com</link>
	<description>Wouldn&#039;t you rather be writing code?</description>
	<lastBuildDate>Sun, 14 Mar 2010 03:02:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WebBrowser.DocumentComplete Firing Multiple Times: Solution</title>
		<link>http://thepursuitofalife.com/webbrowserdocumentcomplete-firing-multiple-times-solution/</link>
		<comments>http://thepursuitofalife.com/webbrowserdocumentcomplete-firing-multiple-times-solution/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 21:19:50 +0000</pubDate>
		<dc:creator>Anthony Stevens</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[DocumentCompleted]]></category>
		<category><![CDATA[ReadyState]]></category>
		<category><![CDATA[Snapper]]></category>
		<category><![CDATA[WebBrowser]]></category>

		<guid isPermaLink="false">http://xidey.wordpress.com/2007/12/29/webbrowserdocumentcomplete-firing-multiple-times-solution/</guid>
		<description><![CDATA[My previous hunch was correct: before you do any actual work in the DocumentComplete event handler, make sure the ReadyState of the control equals &#8220;Complete&#8221;.
Here&#8217;s the updated diagnostic output: notice the time taken drops to three seconds now that I&#8217;m not looping through the worker code eleven different times.
'Snapper.WinForm.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://xidey.wordpress.com/2007/12/29/webbrowserdocumentcompleted-firing-multiple-times/">previous hunch</a> was correct: before you do any actual work in the DocumentComplete event handler, make sure the ReadyState of the control equals &#8220;Complete&#8221;.</p>
<p>Here&#8217;s the updated diagnostic output: notice the time taken drops to three seconds now that I&#8217;m not looping through the worker code eleven different times.</p>
<p><code>'Snapper.WinForm.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.<br />
Uninitialized<br />
Uninitialized<br />
Uninitialized<br />
Uninitialized<br />
Uninitialized<br />
'Snapper.WinForm.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll'<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
12/29/2007 1:15:03 PM - DocumentCompleted!<br />
12/29/2007 1:15:03 PM - DocumentCompleted!<br />
Interactive<br />
Interactive<br />
Interactive<br />
12/29/2007 1:15:03 PM - DocumentCompleted!<br />
12/29/2007 1:15:03 PM - DocumentCompleted!<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
12/29/2007 1:15:05 PM - DocumentCompleted!<br />
12/29/2007 1:15:05 PM - DocumentCompleted!<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
12/29/2007 1:15:05 PM - DocumentCompleted!<br />
12/29/2007 1:15:05 PM - DocumentCompleted!<br />
12/29/2007 1:15:05 PM - DocumentCompleted!<br />
12/29/2007 1:15:05 PM - DocumentCompleted!<br />
Interactive<br />
12/29/2007 1:15:06 PM - DocumentCompleted!<br />
Complete<br />
12/29/2007 1:15:06 PM - DocumentCompleted!<br />
Doing work..</code></p>
<p>It&#8217;s probably also the case that the WebBrowserDocumentCompletedEventArgs parameter of the DocumentCompleted event handler gives me additional info with which to discriminate this ReadyState. May have to look into that one.</p>
<div class="wlWriterSmartContent" style="display:inline;margin:0;padding:0;">Technorati Tags: <a href="http://technorati.com/tags/Snapper" rel="tag">Snapper</a>,<a href="http://technorati.com/tags/WebBrowser" rel="tag">WebBrowser</a>,<a href="http://technorati.com/tags/DocumentCompleted" rel="tag">DocumentCompleted</a>,<a href="http://technorati.com/tags/ReadyState" rel="tag">ReadyState</a></div>
]]></content:encoded>
			<wfw:commentRss>http://thepursuitofalife.com/webbrowserdocumentcomplete-firing-multiple-times-solution/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>WebBrowser.DocumentCompleted Firing Multiple Times</title>
		<link>http://thepursuitofalife.com/webbrowserdocumentcompleted-firing-multiple-times/</link>
		<comments>http://thepursuitofalife.com/webbrowserdocumentcompleted-firing-multiple-times/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 21:02:33 +0000</pubDate>
		<dc:creator>Anthony Stevens</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[DocumentCompleted]]></category>
		<category><![CDATA[Snapper]]></category>
		<category><![CDATA[WebBrowser]]></category>

		<guid isPermaLink="false">http://xidey.wordpress.com/2007/12/29/webbrowserdocumentcompleted-firing-multiple-times/</guid>
		<description><![CDATA[I&#8217;m running in to the same problem that Adi ran into wherein the DocumentCompleted event of the WebBrowser control is firing more than once.  Sometimes a lot of times!
Seems to me that this should be a Once and Only Once type of thing.
Here&#8217;s my diagnostic output when I open techcrunch.com: the timestamped lines are [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m running in to the same problem that Adi ran into wherein <a href="http://dotmad.blogspot.com/2007/05/webbrowserdocumentcompleted-is-raised.html">the DocumentCompleted event of the WebBrowser control is firing more than once</a>.  Sometimes a lot of times!</p>
<p>Seems to me that this should be a <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">Once and Only Once</a> type of thing.</p>
<p>Here&#8217;s my diagnostic output when I open techcrunch.com: the timestamped lines are the DocumentCompleted events; the others are the ProgressChanged events.</p>
<p><code>'Snapper.WinForm.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.<br />
Uninitialized<br />
Uninitialized<br />
Uninitialized<br />
Uninitialized<br />
Uninitialized<br />
'Snapper.WinForm.vshost.exe' (Managed): Loaded 'C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a\Microsoft.mshtml.dll'<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
12/29/2007 1:00:23 PM - DocumentCompleted!<br />
12/29/2007 1:00:24 PM - DocumentCompleted!<br />
12/29/2007 1:00:25 PM - DocumentCompleted!<br />
Interactive<br />
Interactive<br />
12/29/2007 1:00:27 PM - DocumentCompleted!<br />
12/29/2007 1:00:29 PM - DocumentCompleted!<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
12/29/2007 1:00:31 PM - DocumentCompleted!<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
Interactive<br />
12/29/2007 1:00:33 PM - DocumentCompleted!<br />
Interactive<br />
12/29/2007 1:00:35 PM - DocumentCompleted!<br />
12/29/2007 1:00:36 PM - DocumentCompleted!<br />
Interactive<br />
Interactive<br />
12/29/2007 1:00:40 PM - DocumentCompleted!<br />
Complete<br />
12/29/2007 1:00:41 PM - DocumentCompleted!</code></p>
<p>Aside from the fact that it took 18 seconds to get this page&#8217;s contents in code (whereas FasterFox reports 8 seconds in Flock), having 11 DocumentCompleted events seems a little odd.</p>
<p><b>UPDATE:</b> Looking at this the answer seems to pop out at me.  Just wait for the ProgressChanged event to change to &#8220;Complete&#8221; before I do anything meaningful in the DocumentCompleted event handler.  I&#8217;ll give that a try right now.</p>
<div class="wlWriterSmartContent" style="display:inline;margin:0;padding:0;">Technorati Tags: <a href="http://technorati.com/tags/Snapper" rel="tag">Snapper</a>,<a href="http://technorati.com/tags/WebBrowser" rel="tag">WebBrowser</a>,<a href="http://technorati.com/tags/DocumentCompleted" rel="tag">DocumentCompleted</a></div>
]]></content:encoded>
			<wfw:commentRss>http://thepursuitofalife.com/webbrowserdocumentcompleted-firing-multiple-times/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mini Project I&#8217;ll Be Working On</title>
		<link>http://thepursuitofalife.com/mini-project-ill-be-working-on/</link>
		<comments>http://thepursuitofalife.com/mini-project-ill-be-working-on/#comments</comments>
		<pubDate>Fri, 28 Dec 2007 03:43:11 +0000</pubDate>
		<dc:creator>Anthony Stevens</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Screenshot]]></category>
		<category><![CDATA[WebBrowser]]></category>

		<guid isPermaLink="false">http://xidey.wordpress.com/2007/12/27/mini-project-ill-be-working-on/</guid>
		<description><![CDATA[I decided to go ahead and follow through on my research a couple weeks ago into image-processing routines to take screenshots and create a little ecosystem of client apps that will leverage this library:

Now that I know what I know about the WebBrowser class, the missing DrawToBitmap() function, and the GDI32 / USER32 library calls [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to go ahead and follow through on <a href="http://xidey.wordpress.com/2007/12/12/the-missing-drawtobitmap-function-in-the-net-webbrowser-class/">my research a couple weeks ago into image-processing routines to take screenshots</a> and create a little ecosystem of client apps that will leverage this library:</p>
<p><a href="http://thepursuitofalife.com/wp-content/uploads/2007/12/screenieapp.png" title="Screenie App 2"><img src="http://thepursuitofalife.com/wp-content/uploads/2007/12/screenieapp.png" alt="Screenie App 2" style="border-width:0;" /></a></p>
<p>Now that I know what I know about the WebBrowser class, the missing DrawToBitmap() function, and the GDI32 / USER32 library calls from managed .NET code, the core library probably won&#8217;t be that difficult.  I think the hardest part will be &#8220;stitching&#8221; together the various parts of a full-height web page that extends beyond the viewable window.  But hey, any problem you can describe is a problem half-solved.</p>
<p>Updates to come.</p>
]]></content:encoded>
			<wfw:commentRss>http://thepursuitofalife.com/mini-project-ill-be-working-on/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The missing DrawToBitmap() function in the .NET WebBrowser class</title>
		<link>http://thepursuitofalife.com/the-missing-drawtobitmap-function-in-the-net-webbrowser-class/</link>
		<comments>http://thepursuitofalife.com/the-missing-drawtobitmap-function-in-the-net-webbrowser-class/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 05:32:35 +0000</pubDate>
		<dc:creator>Anthony Stevens</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[DrawToBitmap]]></category>
		<category><![CDATA[mshtml]]></category>
		<category><![CDATA[WebBrowser]]></category>

		<guid isPermaLink="false">http://xidey.wordpress.com/2007/12/12/the-missing-drawtobitmap-function-in-the-net-webbrowser-class/</guid>
		<description><![CDATA[The last couple days I&#8217;ve been farting around with how to get access to a rendering engine in order to do screenshots of web pages.  My first attempts were based on the Gecko engine used in Mozilla browsers, and I didn&#8217;t have much luck with Mono or the C# wrappers around the Gtk/Gecko libraries.
Browsing [...]]]></description>
			<content:encoded><![CDATA[<p>The last couple days I&#8217;ve been farting around with how to get access to a rendering engine in order to do screenshots of web pages.  <a href="http://xidey.wordpress.com/2007/12/10/first-attempts-at-mono-c-on-windows/">My first attempts were based on the Gecko engine</a> used in Mozilla browsers, and I didn&#8217;t have much luck with Mono or the C# wrappers around the Gtk/Gecko libraries.</p>
<p>Browsing around some more I found some source for the Microsoft rendering engine (aka Trident) as encapsulated in the older-style SHDOCVW/MSHTML libraries.  Then I quickly found that as of .NET 2.0, there was a new control, System.Windows.Forms.WebControl, that allowed you to embed a browser in your application, with the same semantics as the old style, but which was easier to use.  I remember back in the day trying to get the first IE ActiveX controls on some dumb VB form or another and thinking &#8220;how goddamned fragile can they make this thing?&#8221;  Anyway, that new class discovery led me to <a href="http://daron.yondem.com/default.aspx?month=2006-12">this code</a> which works great &#8212; see the screenshot below, taken at 1024&#215;768, of this blog.  Good enough to get started.</p>
<p>But all along I&#8217;d been doodling with the WebBrowser control class and never saw this neat method <strong>DrawToBitmap()</strong> in intellisense.  Hm.  Strange enough.  I thought maybe it had been deprecated in .NET 3.5, so I fiddled around with changing the Framework Target but no, it has been out of Intellisense since at least Visual Studio 2005.  I found out why when I F1-ed the method:</p>
<p><code><strong>WebBrowserBase.DrawToBitmap Method</strong><br />
This method supports the .NET Framework infrastructure and is not intended to  be used directly from your code.</code></p>
<p>&#8230; and yet it works.  I&#8217;m actually surprised it even compiles.</p>
<p>Poking around even further, I found <a href="http://thoughtpad.net/alan-dean/web-page-image-thumbnail.html">a more &#8220;nativist&#8221; approach from Alan Dean</a> that brings back the mshtml, GDI32, and USER32 libs.   mshtml can be referenced directly as c:\program files\microsoft.net\primary interop assemblies\microsoft.mshtml.dll, but the other two require the DllImports voodoo from the bad old days of yore.  So, I have the resources now to do what it was I wanted to do in the first place, which was&#8230;.what again?  I seem to remember looking at the <a href="http://xidey.wordpress.com/2007/12/06/amazoncom-associates-program/">Amazon Associates Program</a>, seeing a reference to the Alexa Site Thumbnail service, and thinking &#8220;how hard can that be?&#8221;</p>
<p>I think that the Windows code I&#8217;ve found to date can be updated in two significant ways:</p>
<ol>
<li>ensure you can do full-page snapshots if necessary, not just the current viewport.</li>
<li>return the PNG file as an .ashx stream, not necessarily saving the image first.  Of course you could cache the image and still serve it up as an .ashx, I suppose, saving some network traffic.</li>
</ol>
<p>It&#8217;s been an interesting exploration!</p>
]]></content:encoded>
			<wfw:commentRss>http://thepursuitofalife.com/the-missing-drawtobitmap-function-in-the-net-webbrowser-class/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
