Deleting all RSS feeds in IE7

Wed, August 2, 2006, 02:46 PM under IE7 RSS

We already looked at how I deleted all the feeds in Outlook 2007 in one go, and not one by one.

Luckily IE7 understands folder structures from opml but somehow I managed to get them all in a flat list in IE as well (probably outlook messed that up for me or maybe a glitch with IE7 Beta 2 that I was using or something else, not important now).

So how do you delete all feeds in IE7? Out of the box you can't. Fastest end user way would be to create a folder and drag them all in it one-by-one and then delete the folder - yuck!

Another way is to be stupid and delete the contents of the Windows RSS Platform store directly (after shutting down all apps that use it, including IE7 of course). The feed store currently (Beta 3) is here:
"[drive letter]:\Documents and Settings\[user name]\Local Settings\Application Data\Microsoft\Feeds\[your feeds and folders]"

For me however, this was the opportunity I needed to test drive the RSS API. Unfortunately, it is so easy to use that I could achieve what I wanted with a dozen lines of code so here is my simple effort:

using Microsoft.Feeds.Interop;

class Program
{
static void Main(string[] args)
{
IFeedsManager fm = new FeedsManagerClass();
IFeedFolder ff = (IFeedFolder)fm.RootFolder;
System.Console.WriteLine("Starting deletion at root");
DeleteFolder(ff);

System.Console.WriteLine("Deleted all feeds!");
System.Console.ReadLine();
}
private static void DeleteFolder(IFeedFolder ff)
{
DeleteFeedsInFolder(ff);
System.Console.WriteLine();

foreach (IFeedFolder sf in (IFeedsEnum)ff.Subfolders)
{
System.Console.WriteLine("Deleting subfolder '{0}'", sf.Name);
//DeleteFolder(sf); //not needed really but it can demo recursion
sf.Delete();
}
}
private static void DeleteFeedsInFolder(IFeedFolder ff)
{
foreach (IFeed feed in (IFeedsEnum)ff.Feeds)
{
System.Console.WriteLine("Deleting feed {0}", feed.Name);
feed.Delete();
}
}
}
Also note that the code should explicitly release the COM objects. In other words, wherever you have a reference to an object, when you are done with it call:

System.Runtime.InteropServices.Marshal.ReleaseComObject(f);


Deleting all RSS feeds in Outlook 2007

Tue, August 1, 2006, 03:55 PM under IE7 RSS
By now you know that Outlook 12 can be an RSS aggregator. Outlook 2007 has its own RSS engine and does not fully use the Windows RSS Platform. It can share one element of the Windows RSS Platform and that is the Common Feed List. To enable this, go to 'Tools->Options->Other' and click on 'Advanced Options'. On the dialog that comes up, check the checkbox: 'Sync RSS Feeds to the System Feed List' (obvious, right? :-p). For more on outlook and RSS check out the RSS category on Michael Affronti's blog here (I think he owns the feature so you know where feedback on this has to go).

While evaluating whether I want to switch from my current aggregator to the outlook12+IE7 combo, I messed up and ended up with a looong flat list of feeds in Outlook (since outlook doesn't understand folder hierarchy in opml). So I wanted to delete *all* the feeds and while I can do that one by one, there was no mechanism to just get rid of all of them in one go (no folder multiselect).

In case you are wondering, even if you delete the subscriptions from outlook through the 'RSS Feeds' tab on the 'Tools->Account Settings' dialog, all the feed folders you have under the 'RSS Feeds' folder remain (kind of makes sense so you don't lose any cached content). Also note that by default the RSS subscriptions are stored on exchange (which is good because you have access to them from multiple machines through OWA, but also can be bad if your server pst size limit is small).

So anyway, this is unsupported and not recommended and definitely comes with no warranties and everything else in my disclaimer applies. With that out of the way, this is how got rid of all the feeds in one go:
1. Close Outlook 2007 Beta 2
2. Launch Outlook 2003 and connect it to the same exchange server
3. Notice how the RSS Feeds appears as a *regular* folder in Outlook 2003 (it treats it as any other user-created folder)
4. Delete the "RSS Folder" (obviously you can't do that in O12 as it is special, as the icon indicates)

The above worked for me so capturing it here in case it helps anyone but, again, do this at your own risk.

Windows RSS Platform

Mon, July 31, 2006, 03:47 PM under IE7 RSS
The RSS story varies depending on whether you are a publisher, end user or consumer developer. While almost everyone I ask is an end user (via a browser or a rich client aggregator) and many are producers (most commonly blog authors like myself), very few are developers that programmatically consume RSS today. My bet is that this will change going forward with the advent of the Windows RSS Platform.

The Windows RSS Platform ships with IE7 and hence is available not only with Vista but on WinXP too.

It has several elements:
1. Background Download component
2. Common Feed List
3. Store of feed items
4. Store of enclosures (think attachments, e.g. think podcasts)
5. RSS Object Model (more on the API in a later post)

Applications running on Windows have a choice as to which of these components they want to use - in other words it is not an all or nothing approach. For example IE7 uses the lot while Outlook 2007 optionally uses the Common Feed List (more on O12 later).

I am not going to drill into any of the above since there are mountains of information out there. Below are some links to get you started:

- The BTB033 session at Mix06
(also, if you can get hold of the PDC2005 material, check out the session on 'RSS in Windows Vista' again by Walter vonKoch - that was a clue as to who you should send any feedback that you have)

- A handful of overviews on MSDN

- An older article on MSDN

- RSS platform on the RSS Team blog

Glass in C#, an alternative approach

Sun, July 30, 2006, 03:46 PM under Windows | Vista
My blog post on extending Windows Vista's glass into the client area of managed applications seems to have drawn a lot of attention (and some questions). If you haven't already, please read glass and C# (it assumes you are already familiar with Glass on Vista).

In that approach we looked at 5 steps. There is an alternative approach to extending glass with C# on Vista. The alternative approach has the same 1st and 2nd steps. The step that changes is the 3rd step: explicitly using a black brush to paint the extended area of the form in the form's paint event handler.

Rather than do that, do this:
3. Place a panel on the form's top edge, set the panel's BackColor to color X and then set the form's TransparencyKey to the same color X.

When you run the application, the area occupied by the panel will have the glass effect :-)

Note that just using the BackColor of a panel combined with TransparencyKey of form, results in transparency (also applicable to WinXP). The fact that we do that on Vista in an area that we extended with DwmExtendFrameIntoClientArea, is what gives it the glass effect.

This approach of using panels and transparency was first described (afaik) by Tim Sneath here. If you read the comments on Tim's blog post you'll find a heap of unanswered questions regarding a fundamental problem: At runtime, clicking anywhere on the glass area, actually brings to the front the application behind it. In other words, there is true transparency i.e. inability to click on the glass area while retaining focus in this application.

The solution to the problem actually lies in what color you pick. Above I state that you should pick color X but I have not said what X must be. In Tim's example, he picked Gainsboro. If you look at Gainsboro it has the following values: R=220, G=220, B=220. The problem of the unwanted true transparency stems from the fact that all values are equal. So if you just change for example the R to be 221, then the problem goes away :-) Another gotcha if you create your own color is setting the Alpha of the color to anything but 255 (doing that will not render as glass).

So, now we have two approaches for achieving the same goal (I still prefer the explicit black painting) and you can download a project with the transparencykey approach here. Before I finish off, it is worth pointing out that when a window is maximized, any glass area appears black, which is the reason that most windows rendered fully in glass, do not offer a maximize button (to the dismay of Goths I guess :-p).



While from a practical point of view it all works, some of you will have open questions such as "why black?" and "what makes one color result in true transparency while another doesn't". I'll try to answer those in a future blog entry (if no one else beats me to it).
--
UPDATE: This one does not work post-RC1. See here

Vista: User Account Control

Sat, July 29, 2006, 02:30 PM under Windows | Vista | UAC
You, yes *you*, may not be gearing up to Windows Vista just yet but there is one core security element of Vista that IMO you must understand as soon as possible, and start working for it today on whatever Windows OS you are on. The feature in question is User Account Control. Please follow the links from item 5 here (it allows me a central place for updating resources).

Now that you've read those, I hope you understand UAC. In essence, when you set up user accounts on Vista, even if you set some of them as administrator, all interactive processes will run as standard user! The benefit is that any malicious code that gets on the user's machine also runs as standard user. If your applications require administrator privileges for some features, they will basically break on Vista (oversimplification aimed to scare you, but essentially true if you choose to ignore understanding UAC).

To work with this security feature, you must understand elevation, shields, virtualisation and security configuration options plus what you need to do programmatically for you applications to run on Vista. So, watch my nugget here or download it here to get the full picture...

There is one important bit of UAC that I do not cover in that short video (due to time): manifests. So after you’ve watched the video, come back and continue reading…

Fundamentally, on Vista you should declare that your app is aware of UAC (logo certification requirement). To do that you must embed a manifest in your application. Here are the steps on how to do that for managed applications in Visual Studio 2005 on Windows Vista:

1. Add to your VS2005 C# project this manifest file (replacing MyProjectNamewith your actual project name). Open the file in notepad and replace MyProjectNamewith your actual project name, same for description and Version.
2. Add this rc file to your project (replacing MyProjectName with your actual project name and removing the .txt extension). Open it with notepad and change MyProjectName to your actual project name.
3. Open your project file (csproj) in your favorite XML editor, scroll to the bottom and add/paste the following just before the closing Project element (replacing MyProjectNamewith your actual project name):
<propertygroup>
<win32resource>MyProjectName.res</win32resource>
</propertygroup>
<propertygroup>
<prebuildevent>"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\rc.exe" "$(ProjectDir)$(ProjectName).rc"</prebuildevent>
</propertygroup>

4. Rebuild!

The big clue that this has worked for you, apart from no compilation errors, is that virtualization gets turned off for your app (regardless of the security policy setting, which I show in my nugget). Try writing to HKLM and watch it fail with the manifest and succeed without.

If you change the level attribute of the requestedExecutionLevel element in the manifest from asInvoker to requireAdministrator, then you'll get the elevation prompt at startup (do this only if your app is explicitly aimed at administrators).
--
UPDATE: Also see this

Screencast on TaskDialog, CommandLink, cue banner

Sat, July 29, 2006, 02:20 PM under Windows | Vista
Regular readers will have read my previous blog entries on TaskDialog and TaskDialogIndirect. For the full C++ story on TaskDialog in depth read this.

You will have also read about CommandLink, TextBox cue banner and VistaBridge (that also includes the new CommonFileDialog).

Now you can enjoy all that in a short video I created (especially useful for seeing the above in action for those of you not running Windows Vista yet).

Watch it here (wmv) or download it here (zip).

My nuggets are up

Tue, July 18, 2006, 07:52 AM under Links
…just got word that they are finally available for your viewing pleasure so go check out my nuggets!

1. Under "Filter nuggets by" go to the "Presenter" listbox and select "Daniel Moth".
2. Click the "Search" button.
3. From the list of nuggets select the ones of interest and the "Add to My Downloads".
4. In the top right panel under "My Downloads" you can watch/download the nuggets.

Nuggets are basically short (10'-20') pre-recorded videos that have minimal slides and capture the presenter's screen & voice while they demonstrate some technology feature.

Other sites call nuggets, screencasts (not to be confused with webcasts, which are longer online presentations with a live audience).

see you at MGX and TechReady

Fri, July 14, 2006, 04:31 PM under Events
...if you are a Microsoft employee that is...

MGX is Microsoft's global sales conference and TechReady is the internal technical conference (think TechEd for MSFT personnel only).

I am thrilled to be attending TechReady3 in Seattle and also looking forward to catching up with people in Redmond that I know from my MVP days and others that I have only met virtually since joining here.

I cannot put my hand on heart and say that I am "super-excited" to be going to MGX (and probably won't ever go again) but everybody has to do it once… apparently. Having said that, MGX is in Orlando and I haven't been there before so that's cool. If I am lucky I will do some SCUBA diving and maybe go say hello to mickey mouse (no I am not talking about any current or ex-colleagues :-p).

Not sure if I'll blog or check email that often from the States so wish me a nice holiday business trip.

Flying out in a few hours and will be back in August :-)

Vista: CommandLink Button

Thu, July 13, 2006, 08:57 PM under Windows | Vista
I've been holding back on talking about CommandLink (and other Vista features) becuase I have been waiting for my "productions" to appear on msdn. By productions I mean a few short videos recorded with Camptasia... by the time they have been through bureaucracy cubed though, Vista will probably be on version 3.. LOL.. anyway..

CommandLink is a new style of button in Vista. If you want to see what it looks like, take a trip back to my TaskDialog post.

If you followed the link, you saw those squares with a green arrow and two pieces of text: "instruction" and "text". The "instruction" bit is the normal button text we know and love. The "text" bit is in smaller font and that is where you can add as much detail as you want about the button and its purpose. This is the text that typically today you have to place in a label next to the button or in the button's tooltip. Finally, although in my screenshot you can see the square rectangle around the button, when you hover the mouse away from the button, the rectangle fades away (harder to describe than to see which is why I was waiting for the video to go up before describing these).

Kenny Kerr (C++ guru) demonstrates how to do CommandLinks from native code in his msdn article.

Catherine Heller provided my colleague Eric Nelson here in the UK with some code that lets us use CommandLink from C# code. By bizarre coincidence (or is it outright plagiarism?) I use similar code in my Vista talks :-)

Get the CommandLinkButton code here and remember that this works on Windows Vista only.

TextBox with cue banner support for Windows Mobile

Thu, July 13, 2006, 07:30 PM under MobileAndEmbedded
When talking about TextBox with cue banner I thought I had done a good job at the end of the post of hinting that someone should write a pure managed version; a version that is not restricted to Windows Vista, but rather would work on WindowsCE/WindowsMobile devices (via the .NET Compact Framework of course).

Since nobody stepped up, I thought I'd tackle it myself :-). I have to say that what I thought would be a 10 minute job ended up taking 6 times as long and right about now I give up as what I have is good enough and a nice starter for someone else to take and polish, iron out any issues etc.

So, with no pinvokes and explicitly tested on WM 5.0 and WinXP, here is the TextBoxWithPrompt code file. Simply save this file and add it to one of your projects and then build all. Now open a form and go to the toolbox where you can drag the TextBoxWithPrompt onto your form and change its TextPrompt property to e.g. “Enter your name”



As always feel free to contact me via the link on the left about my blog entries.