guowee 发表于 2013-1-30 22:49:48

Hiding the Progress Bar of a .NET 2.0 CF WebBrowse

 
<div class="post"><div class="post-main"><div class="post-entry">[转载自:http://www.chriskarcher.net/2008/01/26/hiding-the-progress-bar-of-a-net-20-cf-webbrowser]
 
 
One of the nice additions to the .NET 2.0 Compact Framework is the WebBrowser control. This control has always been present in the full framework, but to implement a web browser on the PocketPC you would have had to either write your own managed wrapper or use an existing one such as OpenNETCF’s HTMLViewer. But now that it’s included in the CF, we should give it a try. Many developers, myself included, use an embedded browser control to display rich, custom formatted content in their .NET apps. You can do this with the WebBrowser class by generating the HTML and setting the DocumentText property on the control. However, the new managed WebBrowser has a major drawback: Everytime you set the DocumentText property it shows a progress bar while loading the content into the browser. As far as I can tell, this behavior is only on Windows Mobile 5 devices, not on PocketPC 2003. Read on to figure out how to disable this behavior.
 
So, here’s what it looks like:
http://www.chriskarcher.net/wp-content/uploads/2008/01/progressbar.png
At first glance, it doesn’t look intrusive. But when you start updating the HTML regularly and the progress bar pops up every time, it starts to look out of place. It would be nice if MS just exposed an option to disable it, but they don’t. We’re going to have to do some work ourselves to get rid of it.
First, some background. In my application, I created a UserControl named WebBrowserPanel. WebBrowserPanel has a single WebBrowser child control which is anchored Top, Right, Bottom, and Left. It has the following constuctor to make it use all the available space:
<div class="dp-highlighter"><div class="bar"><div class="tools">view plaincopy to clipboardprint?
页: [1]
查看完整版本: Hiding the Progress Bar of a .NET 2.0 CF WebBrowse