create an internet explorer toolbar plugin

19
Create an Internet Explorer Plug-In Toolbar Part I This is Part I of a new series on creating IE plug-ins. In this article, I will show you how I ported and debugged an existing project from Code Project. So let’s go! This is what final product will look like. Here are the steps I took to get this plug-in working. 1. Search for available ways/templates to create an IE plug-in Unfortunately I could not find any Internet Explorer plug-in template, neither from Visual Studio 2008 nor from MSDN nor from googling. 2. Search for open source code snippets or project After a bit digging, I found a relevant and promising project: Prafulla Tekawade’s RSS Reader Plug-in for Internet Explorer .

Upload: jessica-chiang

Post on 13-Nov-2014

2.181 views

Category:

Documents


0 download

DESCRIPTION

This article shows how to build an Open Source RSS Reader Plugin for Internet Explorer, using Microsoft Visual Studio 2008

TRANSCRIPT

Page 1: Create an Internet Explorer Toolbar Plugin

Create an Internet Explorer Plug-In Toolbar Part I

This is Part I of a new series on creating IE plug-ins. In this article, I will show you how Iported and debugged an existing project from Code Project. So let’s go! This is what finalproduct will look like.

Here are the steps I took to get this plug-in working.1. Search for available ways/templates to create an IE plug-in

Unfortunately I could not find any Internet Explorer plug-in template, neither from VisualStudio 2008 nor from MSDN nor from googling.

2. Search for open source code snippets or projectAfter a bit digging, I found a relevant and promising project: Prafulla Tekawade’s RSSReader Plug-in for Internet Explorer.

Page 2: Create an Internet Explorer Toolbar Plugin

Getting RSSReaderPlugin to build

I first tried using Visual C++ 2008 Express but to no avails because of missing libraries. Ifinally had to download and install the 90-day trial version of Microsoft Visual Studio, whichI highly recommended. It’s very easy to use and it’s free!! Three months should be enoughtime for you to get your feet wet (very wet) with developing Visual C++ programs.I had to make the following changes to port this RssReaderPlugin, a Visual Studio 6.0project, to a Visual Studio 2008 project. First, double click RssReaderPlugin.sln to startVisual Studio 2008.

The Visual Studio Conversion Wizard would pop up. Click “Next”.

Page 3: Create an Internet Explorer Toolbar Plugin

Keep the default setting (create a backup file) and click “Next” to continue.

Click “Finish”.

Page 4: Create an Internet Explorer Toolbar Plugin

Then click “Close” to close the windows.

When the solution is open, build it by “Build”->”Build Solution”.

Page 5: Create an Internet Explorer Toolbar Plugin

But you will see this error: “Error C2061: syntax error : identifier ‘IWebBrowser2′. Doubleclick the error to get to the violating line.

The IWebBrowser2 class is included in <Exdist.h>. Add the include statement to get rid ofall IWebBrowser2 related errors.

Page 6: Create an Internet Explorer Toolbar Plugin

Build again. This time you will get another error :”error C2664:‘ATL:CWindowImpl<T,TBase>::Create’ : cannot convert parameter 2 from ‘int’ to ‘RECT &’.Double click to get to the violating line.

Change the second argument from NULL to rect.

Build again. This time it should build without error.

Page 7: Create an Internet Explorer Toolbar Plugin

Note that at this point, not only is this project built, the DLL also has been installed,because the author very considerably adding Custom Build Steps. To view, right click theproject name and select “Property” from the drop down list.

Page 8: Create an Internet Explorer Toolbar Plugin

This is the full Command Line entry for Custom Build Step.

Another way you can register the DLL is by using the register.bat already in the Debugdirectory.

Page 9: Create an Internet Explorer Toolbar Plugin

Start a new Internet Explorer instance. The Rss Reader Toolbar already has been enabled.To view the Rss Reader entry from the list of Internet Explorer Add-ons, click “Tools”->”Manager Add-ons”->”Enable or Disable Add-ons”.

There is Rss Reader Toolbar.

Page 10: Create an Internet Explorer Toolbar Plugin

To add it to the viewable panel, go to “View”->”Toolbars”, then click “Rss Reader Toolbar”to check it.

Page 11: Create an Internet Explorer Toolbar Plugin

Then you should see a RssReader toolbar.

Now let’s try running it. Click “Top Story button”.

Ouch! You would see a Debug Assertion Failed message. Don’t worry – we will take care ofit. Click “Retry”.

Page 12: Create an Internet Explorer Toolbar Plugin
Page 13: Create an Internet Explorer Toolbar Plugin

Make sure that RssReaderPlugin project is open and select it from the Possible Debuggerslist.

Click Break.

Go to the source panel. You should see a small Yellow Arrow, indicating the breakpoint. Thisline tells us that uFormat contains DT_MODIFYSTRING option, which tells DrawText tomodify the specified string to match the displayed text. This value has no effect unlessDT_END_ELLIPSIS or DT_PATH_ELLIPSIS is specified. This option is only allowed forWindows CE platform (_WIN32_WCE).

Page 14: Create an Internet Explorer Toolbar Plugin

To find out where DT_MODIFYSTRING option is set (we need to unset it), use the Find andReplace tool from Visual Studio (also available in the Express edition). Go to “Edit”->”Findand Replace”.

Click the first find, which is on line 263 of RRPNewsButton.cpp and delete allDT_MODIFYSTRING from the OR combo.

Page 15: Create an Internet Explorer Toolbar Plugin

Click the second find, which is on line 347 of RRPNewsButton.cpp and delete allDT_MODIFYSTRING from the OR combo.

To compile, click the Stop Debugging button.

Click Continue to keep running to the end.

Page 16: Create an Internet Explorer Toolbar Plugin

Then now rebuild and re-register the DLL. This time it should work without throwingexception.

To view the RSS feed from shallwelearn.com, click the RSS feed button.

Page 17: Create an Internet Explorer Toolbar Plugin

You will be taken to the RSS page of shallwelearn.com, which is:http://shallwelearn.com/index.php?format=feed&type=rss

To set the RSS page to shallwelearn’s RSS feed, click “Rss Reader” to open theConfiguration Settings Window.

Page 18: Create an Internet Explorer Toolbar Plugin

Right now the code will always just shows the first one in the RSS item list, which is “TopStories”, so we copy and paste the ShallWeLearn RSS feed as the Link of the RSS of the TopStories. Click Save to save.

Then “Cancel” to close the pop-up window.

Now if you click Top Stories button, you should see the updated RSS feed.

Page 19: Create an Internet Explorer Toolbar Plugin