<?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>AB-WebLog.com&#187; Internet Explorer</title>
	<atom:link href="http://www.ab-weblog.com/en/tag/internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ab-weblog.com/en</link>
	<description>Andreas Breitschopp</description>
	<lastBuildDate>Wed, 18 Mar 2015 09:47:48 +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>Developing a Browser Toolbar: Microsoft Internet Explorer (3/5)</title>
		<link>http://www.ab-weblog.com/en/developing-a-browser-toolbar-microsoft-internet-explorer/</link>
		<comments>http://www.ab-weblog.com/en/developing-a-browser-toolbar-microsoft-internet-explorer/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 15:00:15 +0000</pubDate>
		<dc:creator>Andreas Breitschopp</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASPects]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[publication]]></category>
		<category><![CDATA[toolbar]]></category>

		<guid isPermaLink="false">http://www.ab-weblog.com/en/?p=291</guid>
		<description><![CDATA[This post series reflects my article &#8220;Developing a Browser Toolbar&#8221; published in the ASPects in January 2010 (Volume 23, Issue 1), a magazine of the Association of Shareware Professionals (ASP). The first decision to make is which programming language you &#8230; <a href="http://www.ab-weblog.com/en/developing-a-browser-toolbar-microsoft-internet-explorer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>This post series reflects my article &#8220;Developing a Browser Toolbar&#8221; published in the <a title="ASPects Website" href="http://www.asp-shareware.org/about/aspects.asp" target="_blank">ASPects</a> in January 2010 (Volume 23, Issue 1), a magazine of the <a title="Association of Shareware Professionals Website" href="http://www.asp-shareware.org" target="_blank">Association of Shareware Professionals</a> (ASP).</em></p>
<p>The first decision to make is which programming language you want to use for developing the Internet Explorer toolbar. I did some research in the web and found examples for C++, Visual Basic 6 and .NET. There seem to be some visual styles issues; it obviously does not look so good on Windows Vista and Windows 7 systems by using the C++ version. And as I really don&#8217;t like to develop in Visual Basic 6 anymore, I decided to go the .NET way. The only disadvantage of this decision is that the user needs to have the .NET Framework 2.0 (or higher) installed on the system. But I can live with that, because it is very common already.</p>
<p>Since almost all of my products are developed in .NET, I already had the Visual Studio 2008 installed on my computer. If not, you&#8217;ll need at least the <a title="Microsoft Visual Studio Express Edition Website" href="http://www.microsoft.com/express" target="_blank">Express Edition</a> (version 2005 should be enough, too) for the next steps. I decided to develop the toolbar in C#, but Visual Basic .NET could do the same thing, of course.</p>
<p>As a good starting point I found <a title="Extending Explorer With Band Objects Using .NET and Windows Forms" href="http://www.codeproject.com/KB/shell/dotnetbandobjects.aspx" target="_blank">this</a> and <a title="Internet Explorer Toolbar Creation" href="http://www.codeproject.com/KB/shell/IEToolbar.aspx" target="_blank">this</a> article at the Code Project webpage. If you want to read more about the COM component, you can also read the <a title="Internet Explorer Toolbar (Deskband) Tutorial" href="http://www.codeproject.com/KB/shell/ietoolbartutorial.aspx" target="_blank">C++ tutorial</a>, but that&#8217;s not necessarily needed. By using the demo source code of those articles you should get a working toolbar – at least on a Windows XP system. But there were some issues I came across that needed to be fixed and therefore I will describe them in more detail here:</p>
<h2>Making Toolbar Show up Correctly on All Operating Systems</h2>
<p>By using the demo code of the articles mentioned above, I got the toolbar to work quite fast on my Windows XP testing machine. I was naively thinking that if the toolbar works on Windows XP with Internet Explorer 8, it will also work on Windows Vista and Windows 7 with the same Internet Explorer version. But indeed, I had to learn that this is absolutely not the case! It either just does not show up at all or so far on the right side, that you can only see the toolbar if you have a horizontal resolution of at least 2,000 pixels. So I had to search for a solution, but most changes to the code resulted in the toolbar working either on the one or on the other operating system or browser version combination. After some hours of frustrated testing, I changed the <em>GetBandInfo</em> procedure of the <em>BandObjectsLib</em> class in the following way. Although I&#8217;m still not absolutely sure why, it works fine now on all operating system:</p>
<pre class="brush: csharp; gutter: true">public virtual void GetBandInfo(UInt32 dwBandID, UInt32 dwViewMode, ref DESKBANDINFO dbi)
{
    if ((dbi.dwMask &amp; DBIM.MINSIZE) != 0)
    {
        dbi.ptMinSize.X = this.MinimumSize.Width;
        dbi.ptMinSize.Y = this.MinimumSize.Height;
    }

    if ((dbi.dwMask &amp; DBIM.MAXSIZE) != 0)
    {
        dbi.ptMaxSize.X = this.MaximumSize.Width;
        dbi.ptMaxSize.Y = this.MaximumSize.Height;
    }

    if ((dbi.dwMask &amp; DBIM.ACTUAL) != 0)
    {
        dbi.ptActual.X = this.Size.Width;
        dbi.ptActual.Y = this.Size.Height;
    }

    if ((dbi.dwMask &amp; DBIM.BKCOLOR) != 0)
    {
        dbi.dwMask &amp;= ~DBIM.BKCOLOR;
    }

    dbi.dwModeFlags = DBIMF.BREAK;
}</pre>
<h2>Nicer Appearance on Windows XP and above</h2>
<p>If you don&#8217;t add the following event handler to the <em>BandObjectsLib</em> class, your toolbar will still work, but will just not look very good on Windows XP and above. The <em>if</em>-statement in the event function additionally makes sure that the toolbar still works on older operating systems like Windows 98, 2000 and ME. Otherwise it would throw an exception on these operating systems. Here is the code I&#8217;ve used to get it to work correctly on all operating systems:</p>
<pre class="brush: csharp; gutter: true">[DllImport("uxtheme", ExactSpelling = true)]
public extern static Int32 DrawThemeParentBackground(IntPtr hWnd, IntPtr hdc,
                                                     ref Rectangle pRect);

protected override void OnPaintBackground(PaintEventArgs e)
{
    if (System.Environment.OSVersion.Platform &gt;= PlatformID.Win32NT &amp;&amp;
           (Environment.OSVersion.Version.Major == 5 &amp;&amp;
            Environment.OSVersion.Version.Minor &gt;= 1 ||
            Environment.OSVersion.Version.Major &gt;= 6) &amp;&amp;
           this.BackColor == Color.Transparent)
    {
        // Only if operating system is Windows XP or higher
        IntPtr hdc = e.Graphics.GetHdc();
        Rectangle rec = new Rectangle(e.ClipRectangle.Left,
            e.ClipRectangle.Top, e.ClipRectangle.Width, e.ClipRectangle.Height);
        DrawThemeParentBackground(this.Handle, hdc, ref rec);
        e.Graphics.ReleaseHdc(hdc);
    }
    else
    {
        base.OnPaintBackground(e);
    }
}</pre>
<h2>No Serialization Allowed</h2>
<p>When developing a Firefox toolbar you can use the Mozilla preferences service to store and load user-defined values inside Firefox itself. Because there is no equivalent in Internet Explorer and I&#8217;m using XML serialization in many of my other .NET products, I wanted to use it in the toolbar project, too. This worked fine at first sight, but if the <em>Protected Mode</em> is enabled in Internet Explorer 8 (and it is by default, at least since Windows Vista), it shows an ugly warning dialog to the user whenever the toolbar is initialized. I won&#8217;t explain the reason in detail here, but just don&#8217;t use serialization in Internet Explorer toolbars. You can save user-defined values either without serialization in the file system below the local application data directory or simply by using the registry.</p>
<h2>Automatic Online Update</h2>
<p>As I did in the Firefox version, I also wanted the Internet Explorer toolbar to come with an automatic update feature. Because there is no update system for toolbars in Firefox, you have to implement it yourself. But this is quite easy, because you can use, as in any other .NET application, the <em>WebClient</em> class for doing a HTTP request to first ask if there is a new update available and then to receive the update file if needed. On the server side I have a small PHP script handling the update requests. The update file which is downloaded is the normal setup executable that just overrides all files with the new ones. The only thing you have to care about is the way you call the executable setup file after downloading, because otherwise a User Account Control (UAC) prompt will be shown. I&#8217;ve written this procedure that you can use for executing a file from within the toolbar code without any warning displayed to the user:</p>
<pre class="brush: csharp; gutter: true">private void startProcess(string fileName, string arguments)
{
    System.Diagnostics.ProcessStartInfo startInfo =
        new System.Diagnostics.ProcessStartInfo();
    startInfo.UseShellExecute = true;
    startInfo.WorkingDirectory = Environment.CurrentDirectory;
    startInfo.FileName = fileName;
    if (Environment.OSVersion.Platform &gt;= PlatformID.Win32NT &amp;&amp;
            Environment.OSVersion.Version.Major &gt;= 6)
        // Only if operating system is Windows Vista or higher
        startInfo.Verb = "runas";
    else
        startInfo.Verb = "open";
    startInfo.Arguments = arguments;
    startInfo.ErrorDialog = true;
    try
    {
        System.Diagnostics.Process process = System.Diagnostics.Process.Start(startInfo);
        process.WaitForExit();

        MessageBox.Show(objToolbarData["msg.restartBrowserText"],
                        objToolbarData["msg.restartBrowserTitle"],
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    catch (Exception ex)
    {
        if (debugMode) MessageBox.Show(ex.ToString());
    }
}</pre>
<h2>Uninstall Button Inside the Toolbar</h2>
<p>That&#8217;s the only thing which is easier to implement in Internet Explorer than in Firefox; it is enough to call the uninstall executable (again with the <em>startProcess</em> procedure above) of the installation system (see next post###) to uninstall the toolbar again. It will disappear then after browser has been restarted (just as on Firefox).</p>
<p>It&#8217;s done; the Internet Explorer version of our toolbar is ready, too! It will work on Internet Explorer 6 or higher running on Windows 98 or higher with an installed .NET Framework 2.0.</p>
<p>In the <a title="Developing a Browser Toolbar: Installation System (4/5)" href="http://www.ab-weblog.com/en/developing-a-browser-toolbar-installation-system/">next post</a> I&#8217;ll explain how we get the toolbars installed.</p>
<h2>Contents of Post Series &#8220;Developing a Browser Toolbar&#8221;:</h2>
<ul>
<li><a title="Developing a Browser Toolbar: Introduction (1/5)" href="http://www.ab-weblog.com/en/developing-a-browser-toolbar-introduction/">Introduction</a></li>
<li><a title="Developing a Browser Toolbar: Mozilla Firefox (2/5)" href="http://www.ab-weblog.com/en/developing-a-browser-toolbar-mozilla-firefox-25/">Mozilla Firefox</a></li>
<li>Microsoft Internet Explorer</li>
<li><a title="Developing a Browser Toolbar: Installation System (4/5)" href="http://www.ab-weblog.com/en/developing-a-browser-toolbar-installation-system/">Installation System</a></li>
<li><a title="Developing a Browser Toolbar: Summary (5/5)" href="http://www.ab-weblog.com/en/developing-a-browser-toolbar-summary/">Summary</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.ab-weblog.com/en/developing-a-browser-toolbar-microsoft-internet-explorer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->