<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The Windows 7 Blog for Developers : Code samples</title><link>http://blogs.msdn.com/yochay/archive/tags/Code+samples/default.aspx</link><description>Tags: Code samples</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Windows 7 Taskbar – Part 1, The Basics</title><link>http://blogs.msdn.com/yochay/archive/2009/01/06/windows-7-taskbar-part-1-the-basics.aspx</link><pubDate>Tue, 06 Jan 2009 04:37:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9284385</guid><dc:creator>yochayk</dc:creator><slash:comments>14</slash:comments><comments>http://blogs.msdn.com/yochay/comments/9284385.aspx</comments><wfw:commentRss>http://blogs.msdn.com/yochay/commentrss.aspx?PostID=9284385</wfw:commentRss><description>&lt;P&gt;This post is one of a series of Windows 7 Taskbar posts and webcasts. You can watch &lt;B&gt;&lt;A href="http://channel9.msdn.com/posts/yochay/Jump-into-the-Windows-7-Taskbar-Jump-Lists/" mce_href="http://channel9.msdn.com/posts/yochay/Jump-into-the-Windows-7-Taskbar-Jump-Lists/"&gt;Jump into the Windows 7 Taskbar Jump Lists&lt;/A&gt;&lt;/B&gt; webcast on Channel 9 for further technical information, or the &lt;STRONG&gt;&lt;A href="http://channel9.msdn.com/posts/yochay/Windows-7-New-Taskbar-an-overview/" mce_href="http://channel9.msdn.com/posts/yochay/Windows-7-New-Taskbar-an-overview/"&gt;entire Windows 7 Taskbar webcasts series&lt;/A&gt;&lt;/STRONG&gt;. You can also download the code sample.&lt;/P&gt;
&lt;P&gt;One of the first Windows 7 changes that developers should pay attention to is the new Windows Taskbar. This new feature introduces a functionality that developers need to understand so they can take full advantage of it in their own applications to better enhance their end users’ experiences.&lt;/P&gt;
&lt;P&gt;The new Taskbar is the most noticeable change to Windows 7 when you first log on. The Windows 7 Taskbar is an application-launching and window-switching mechanism that consolidates the functionalities from previous Windows Desktop mechanisms such as Quick Launch, Recent Documents, Notification area icons, desktop shortcuts, and running application windows. &lt;/P&gt;
&lt;P&gt;If you are unfamiliar with and haven’t seen any demonstrations of the Windows 7 Taskbar, please watch Chitnya’s online &lt;I&gt;Windows 7 Taskbar in Action&lt;/I&gt; demo during his &lt;A href="http://channel9.msdn.com/pdc2008/PC24/" mce_href="http://channel9.msdn.com/pdc2008/PC24/"&gt;Welcome to the New Desktop&lt;/A&gt; PDC session. This will give you some context for the technical material we are going to cover here. Additional information about the Windows 7 Taskbar can be found in &lt;A href="http://blogs.msdn.com/e7/archive/2008/11/20/happy-anniversary-windows-on-the-evolution-of-the-taskbar.aspx" mce_href="http://blogs.msdn.com/e7/archive/2008/11/20/happy-anniversary-windows-on-the-evolution-of-the-taskbar.aspx"&gt;The Windows 7 Taskbar&lt;/A&gt; E7 blog and in Channel 9&lt;A href="http://channel9.msdn.com/posts/yochay/Windows-7-New-Taskbar/" mce_href="http://channel9.msdn.com/posts/yochay/Windows-7-New-Taskbar/"&gt; Windows Taskbar Webcast series&lt;/A&gt;. &lt;/P&gt;
&lt;P&gt;In this article, we address Windows 7 Taskbar functionality and provide a high-level overview of its programming model to help developers to better prepare for Windows 7. Obviously, this will not be a comprehensive step-by-step developer guide to the Windows 7 Taskbar, but rather a broad overview. Please look for additional content about the Windows 7 taskbar in future posts. &lt;/P&gt;
&lt;P&gt;The Windows 7 Taskbar is designed to provide users with quick and easy access to those “things” they use all the time. “Things” can be any type of content such as pictures, music, word documents or links and shortcuts to applications or folders. By quick and easy access, we mean accessing commonly used programs with a single mouse click or significantly reducing the number of clicks per operation. Quick and easy access also means users should be able to “jump” directly to those things they want to work with and start working with them in a single mouse click. To provide this functionality, Windows 7 Taskbar introduces the concept of “Jump Lists.”&lt;/P&gt;
&lt;P&gt;As a developer, think of Jump Lists as your own mini Start Menu for &lt;A href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/Windows7TaskbarPart1TheBasics_F7BD/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/Windows7TaskbarPart1TheBasics_F7BD/image_2.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; MARGIN: 5px 5px 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image align=right src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/Windows7TaskbarPart1TheBasics_F7BD/image_thumb.png" width=124 height=240 mce_src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/Windows7TaskbarPart1TheBasics_F7BD/image_thumb.png"&gt;&lt;/A&gt;your application. Jump Lists surface commonly used nouns (destinations) and verbs (tasks) of a program, enabling easy user access to destinations by eliminating the need to launch the application and then load the relevant content, or by performing common tasks without launching the application in advance. The following diagram illustrates how Jump Lists work with Microsoft Office Word. You can see that under the “Recent” category, there is a list of recent documents that I’ve used with Office Word. Clicking on one of the items in the “Recent” list will launch Office Word with the relevant document already loaded. &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The out-of-the-box experience of the Jump Lists includes only the default &lt;I&gt;Taskbar Tasks.&lt;/I&gt; These provide the means to launch a new instance of the application, to pin or unpin an application to the taskbar, and to close the application. You can access the Jump List by right clicking on an application icon in the Taskbar. However, as the following diagram illustrates, you can opt into the Taskbar experience by customizing the context of the Jump Lists for your application.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/Windows7TaskbarPart1TheBasics_F7BD/image_4.png" mce_href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/Windows7TaskbarPart1TheBasics_F7BD/image_4.png"&gt;&lt;IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: inline; BORDER-TOP: 0px; BORDER-RIGHT: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/Windows7TaskbarPart1TheBasics_F7BD/image_thumb_1.png" width=467 height=266 mce_src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/Windows7TaskbarPart1TheBasics_F7BD/image_thumb_1.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P align=center&gt;Image from Robert Jarrett’s slide deck from his PDC session&lt;/P&gt;
&lt;P&gt;Definitions from the Windows 7 SDK:&lt;/P&gt;
&lt;P&gt;”… &lt;B&gt;&lt;I&gt;Destinations&lt;/I&gt;&lt;/B&gt; are items that appear in the &lt;I&gt;Recent&lt;/I&gt;, &lt;I&gt;Frequent&lt;/I&gt; or custom categories (the “Important” category in the diagram above), based on the user’s items usage. Destination can be files, folders, Web sites or other content-based items, but are not necessarily file-backed. Destinations can be pinned to or removed from the Jump List by the user. They are generally represented by IShellItem objects, but they can also be IShellLink objects…”&lt;/P&gt;
&lt;P&gt;”…&lt;B&gt;&lt;I&gt;Tasks&lt;/I&gt;&lt;/B&gt; are common actions performed in applications that apply to all users of the application regardless of the individual usage patterns. Task can’t be pinned or removed. Tasks are represented by IShellLInk objects because they are actually links (with parameters – optional) to commands – “Actions”…”&lt;/P&gt;
&lt;P&gt;As developers, we can: &lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;B&gt;Control Application Destinations&lt;/B&gt; (that is control the items we want users to be able to “Jump” directly into and start working on) &lt;/LI&gt;&lt;/OL&gt;
&lt;UL&gt;
&lt;UL&gt;
&lt;LI&gt;Destinations can be any one of the known categories such as &lt;I&gt;Recent&lt;/I&gt; or &lt;I&gt;Frequent.&lt;/I&gt;&lt;/LI&gt;
&lt;LI&gt;The &lt;I&gt;Custom&lt;/I&gt; category is just like any other Destination category, except that it allows developers to create a &lt;B&gt;new &lt;/B&gt;name for that category as well as populate it with items.&lt;/LI&gt;
&lt;LI&gt;The &lt;I&gt;Pinned&lt;/I&gt; category is provided for pinned items that users want to keep permanently in their Jump Lists.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;
&lt;P&gt;2. &lt;B&gt;Define common user Tasks&lt;/B&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;UL&gt;
&lt;LI&gt;The Taskbar surfaces its own out-of-the-box tasks such as launching, pinning/unpinning, or closing the application. As developers we have no control over the Taskbar Tasks. However, we do control the User Tasks.&lt;/LI&gt;
&lt;LI&gt;User Tasks are common tasks the application developer wants to surface at the Jump List level that will enable users to perform a task directly from the Jump List (e.g. &lt;I&gt;Play all&lt;/I&gt; music in media player without switching to media player). Usually, this will result in launching an instance of the application and performing the task. Again, this saves time and reduces the number of clicks needed to achieve the same end goal without the Jump List functionality.&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;
&lt;P&gt;It is time we address the Taskbar programming model. The Taskbar exposes its set of APIs like any other Windows Shell component, through a set of COM interfaces. However, there are a few actions we developers can do even before starting to use the Windows Taskbar COM APIs. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Step 1 – Use the Out-of-the-Box Windows Experience and Default Behavior&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;By default, a Jump List contains a &lt;I&gt;Recent&lt;/I&gt; category that is populated automatically for file-based applications through the &lt;B&gt;&lt;I&gt;SHAddToRecentDocs&lt;/I&gt;&lt;/B&gt; function. This function adds the used “item” (document) to the Shell's list of recently used documents. In addition to updating its list of recent documents, the Shell adds a shortcut to the user's &lt;I&gt;Recent&lt;/I&gt; directory. The Windows 7 Taskbar uses that list and Recent directory to populate the list of recent items in the Jump Lists. &lt;/P&gt;
&lt;P&gt;Windows can also do the work for you if your application's file type has a registered handler (this does not have to be the default handler). Anytime you double click on a file type with a registered handler, before Windows launches your application it automatically calls &lt;B&gt;&lt;I&gt;SHAddToRecentDocs&lt;/I&gt;&lt;/B&gt; on your application's behalf. This inserts the item in the Windows Recent list and eventually into the Jump List Recent Category. The same automatic behavior occurs when using the Windows &lt;B&gt;common file dialog&lt;/B&gt; to open files through our applications.&lt;/P&gt;
&lt;P&gt;Both of the above cases exploit default Windows behavior in case you have a registered handler and an Application ID by which the files are assoctiated with &lt;I&gt;Recent&lt;/I&gt; and &lt;I&gt;Frequent&lt;/I&gt; lists. In both cases, Windows automatically inserts the items into the Jump Lists unless you &lt;B&gt;specifically&lt;/B&gt; remove this functionality by using the COM API. Obviously, users also have the option to remove any items from their Jump Lists. By explicitly removing an item from the Jump List, you insert it into the Removed item list, which we will discuss below. &lt;/P&gt;
&lt;P&gt;&lt;B&gt;Step 2 – Create Your Own Category &lt;/B&gt;&lt;/P&gt;
&lt;P&gt;If the default &lt;I&gt;Recent&lt;/I&gt; or &lt;I&gt;Frequent&lt;/I&gt; categories do not meet your application's needs, it is time to create your own &lt;I&gt;custom&lt;/I&gt; category. You need to use the ICustomDestinationList interface to create a custom Destination List.&lt;/P&gt;
&lt;P&gt;The ICustomDestinationList exposes methods that allow an application to provide a custom Jump List, including destinations and tasks, for display in the taskbar. Here are the methods that we are using for the example below:&lt;/P&gt;
&lt;TABLE border=1 cellSpacing=0 cellPadding=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=169&gt;
&lt;P&gt;AppendCategory&lt;/P&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=469&gt;
&lt;P&gt;Defines a custom category and the destinations that it contains, for inclusion in a custom Jump List&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=169&gt;
&lt;P&gt;AppendKnownCategory&lt;/P&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=469&gt;
&lt;P&gt;Specifies that the Frequent or Recent category should be included in the Jump List&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=169&gt;
&lt;P&gt;BeginList&lt;/P&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=469&gt;
&lt;P&gt;Initiates a building session for a custom Jump List&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=169&gt;
&lt;P&gt;CommitList&lt;/P&gt;&lt;/TD&gt;
&lt;TD vAlign=top width=469&gt;
&lt;P&gt;Declares that the Jump List initiated by a call to BeginList is complete and ready for display&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;Here is a code snippet for a function that creates a new custom list called “Custom Lists” and appends 4 items to it:&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; CreateJumpList()&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;{    &lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;    ICustomDestinationList *pcdl;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;    HRESULT hr = CoCreateInstance&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   5: &lt;/SPAN&gt;                    (CLSID_DestinationList, &lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:   &lt;/SPAN&gt;                   NULL, CLSCTX_INPROC_SERVER, &lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;&amp;nbsp;&amp;nbsp; IID_PPV_ARGS(&amp;amp;pcdl));&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (SUCCEEDED(hr))&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;    {&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  11:  &lt;/SPAN&gt;        hr = pcdl-&amp;gt;SetAppID(c_szAppID);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  12:  &lt;/SPAN&gt;        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (SUCCEEDED(hr))&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  13:  &lt;/SPAN&gt;        {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  14:  &lt;/SPAN&gt;            UINT uMaxSlots;&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  15:  &lt;/SPAN&gt;            IObjectArray *poaRemoved;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  16:  &lt;/SPAN&gt;            hr = pcdl-&amp;gt;BeginList&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  17:  &lt;/SPAN&gt;                (&amp;amp;uMaxSlots, IID_PPV_ARGS(&amp;amp;poaRemoved));&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  18:  &lt;/SPAN&gt;            &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (SUCCEEDED(hr))&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  19:  &lt;/SPAN&gt;            {&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  20:  &lt;/SPAN&gt;                hr = _AddCategoryToList(pcdl, poaRemoved);&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  21:  &lt;/SPAN&gt;                &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (SUCCEEDED(hr))&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  22:  &lt;/SPAN&gt;                {&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  23:  &lt;/SPAN&gt;                    pcdl-&amp;gt;CommitList();&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  24:  &lt;/SPAN&gt;                }&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  25:  &lt;/SPAN&gt;                poaRemoved-&amp;gt;Release();&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  26:  &lt;/SPAN&gt;            }&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  27:  &lt;/SPAN&gt;        }&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  28:  &lt;/SPAN&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;&lt;SPAN class=lnum&gt;  29:  &lt;/SPAN&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;DIV class=csharpcode&gt;&lt;PRE class=alt&gt;&lt;SPAN class=rem&gt;// This is the helper function that actually &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=rem&gt;//appends the items to a collection object HRESULT &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;_AddCategoryToList(ICustomDestinationList *pcdl,&lt;/PRE&gt;&lt;PRE&gt;                       IObjectArray *poaRemoved)&lt;/PRE&gt;&lt;PRE class=alt&gt;{&lt;/PRE&gt;&lt;PRE&gt;    IObjectCollection *poc;&lt;/PRE&gt;&lt;PRE class=alt&gt;    HRESULT hr = CoCreateInstance&lt;/PRE&gt;&lt;PRE&gt;(CLSID_EnumerableObjectCollection, &lt;/PRE&gt;&lt;PRE class=alt&gt;NULL, &lt;/PRE&gt;&lt;PRE&gt;CLSCTX_INPROC_SERVER, &lt;/PRE&gt;&lt;PRE class=alt&gt;IID_PPV_ARGS(&amp;amp;poc));&lt;/PRE&gt;&lt;PRE&gt;    &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (SUCCEEDED(hr))&lt;/PRE&gt;&lt;PRE class=alt&gt;    {&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;for&lt;/SPAN&gt; (UINT i = 0; i &amp;lt; ARRAYSIZE(c_rgpszFiles); i++)&lt;/PRE&gt;&lt;PRE class=alt&gt;        {&lt;/PRE&gt;&lt;PRE&gt;            IShellItem *psi;&lt;/PRE&gt;&lt;PRE class=alt&gt;            &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (SUCCEEDED(SHCreateItemInKnownFolder(&lt;/PRE&gt;&lt;PRE&gt;FOLDERID_Documents, &lt;/PRE&gt;&lt;PRE class=alt&gt;KF_FLAG_DEFAULT, &lt;/PRE&gt;&lt;PRE&gt;c_rgpszFiles[i], &lt;/PRE&gt;&lt;PRE class=alt&gt;IID_PPV_ARGS(&amp;amp;psi))))&lt;/PRE&gt;&lt;PRE&gt;            {&lt;/PRE&gt;&lt;PRE class=alt&gt;                &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;(!_IsItemInArray(psi, poaRemoved))&lt;/PRE&gt;&lt;PRE&gt;                {&lt;/PRE&gt;&lt;PRE class=alt&gt;                    poc-&amp;gt;AddObject(psi);&lt;/PRE&gt;&lt;PRE&gt;                }&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;                psi-&amp;gt;Release();&lt;/PRE&gt;&lt;PRE class=alt&gt;            }&lt;/PRE&gt;&lt;PRE&gt;        }&lt;/PRE&gt;&lt;PRE class=alt&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;        IObjectArray *poa;&lt;/PRE&gt;&lt;PRE class=alt&gt;        hr = poc-&amp;gt;QueryInterface(IID_PPV_ARGS(&amp;amp;poa));&lt;/PRE&gt;&lt;PRE&gt;        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (SUCCEEDED(hr))&lt;/PRE&gt;&lt;PRE class=alt&gt;        {&lt;/PRE&gt;&lt;PRE&gt;            pcdl-&amp;gt;AppendCategory(L&lt;SPAN class=str&gt;"Custom category"&lt;/SPAN&gt;, poa);&lt;/PRE&gt;&lt;PRE class=alt&gt;            poa-&amp;gt;Release();&lt;/PRE&gt;&lt;PRE&gt;        }&lt;/PRE&gt;&lt;PRE class=alt&gt;        poc-&amp;gt;Release();&lt;/PRE&gt;&lt;PRE&gt;    }&lt;/PRE&gt;&lt;PRE class=alt&gt;    &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; hr;&lt;/PRE&gt;&lt;PRE&gt;}&lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;STYLE type=text/css&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We started with a call to CoCreateInstance to initialize the &lt;B&gt;ICustomDestinationList&lt;/B&gt; object (this is the joy of working with COM….). Next, we set the Application ID, so we could start populating items to the list. The Application ID is a string the uniquely identifies your application and make sure all the different windows are clustered under the same glom as well as all the files in the &lt;I&gt;Recent&lt;/I&gt; category, however, Application ID is important enough to get its own full blog in the near future.&lt;/P&gt;
&lt;P&gt;Using the &lt;B&gt;BeginList&lt;/B&gt; function initiated the build session for the custom Jump List. Note the &lt;B&gt;Remove&lt;/B&gt; item parameter, IObjectArray *poaRemoved, that the BeginList() returned as an out parameter. We will handle the removed items list below.&lt;/P&gt;
&lt;P&gt;Next we called a helper function, &lt;I&gt;_AddCategoryToList()&lt;/I&gt;, to do the actual work of adding items to the custom category. &lt;/P&gt;
&lt;P&gt;Another new interface, the IObjectCollection, represents a collection of objects that support &lt;B&gt;IUnKnown,&lt;/B&gt; to which we will add the IShellItems. Each item we added is of an &lt;I&gt;IShellItem&lt;/I&gt; type and we created each item in the documents known folder. However, before we actually added the new item to the collection, we needed to check if the user already removed it. If the user explicitly removed an item from the Jump List, that item will be in the &lt;I&gt;Removed Item List&lt;/I&gt; (again associated with the App ID), and, as developers, we need to respect the user's requests and avoid adding that item to the Jump List. We already have the list of removed items, IObjectArray *poaRemoved, that we got when we called the BeginList(…) function when we initiated the process of creating a new list. &lt;/P&gt;
&lt;P&gt;At this stage, we have a collection if IShellItems that the user expects to see in his Jump List. Next we added that collection to the ICustomDestinationList object and created a new category named “&lt;I&gt;Custom category&lt;/I&gt;”, pcdl-&amp;gt;AppendCategory (L"Custom category", poa);. &lt;/P&gt;
&lt;P&gt;We have successful created a new category in the Taskbar called “Custom category” and populated it with four items. However, our work is not done yet. The final step is to call the CommitList() function that ends the "transaction" that began with calling the BeginList() function. Only after our call to CommitList()&lt;B&gt; &lt;/B&gt;are&lt;B&gt; &lt;/B&gt;the new category and new items displayed. Calling CommitList() causes the stored list of removed items to be cleared and a new removed items list to begin. The ICustomDestinationist interface provides a "transactional base" API. In order to ensure a positive end user experience, make sure that a safe copy of the new repopulated list is complete and ready for use, and that the only operation the Taskbar must perform is to switch the pointer to the new list. &lt;/P&gt;
&lt;P&gt;As you can see, it is easy to opt in to the Windows 7 Taskbar functionality. Most of the work is performed automatically by Windows for you, and if you do need to create your own category, that is also very easy. &lt;/P&gt;
&lt;P&gt;There are many more features the new Windows 7 Taskbar that further enhance the user experience, including cool visual and informative notifications using Overlay icons, a Progress Bar indicator, and Thumbnail icons. We will address these features in future posts.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9284385" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/yochay/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Developers/default.aspx">Developers</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Code+samples/default.aspx">Code samples</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Windows+7+Beta/default.aspx">Windows 7 Beta</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Taskbar/default.aspx">Taskbar</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Channel+9/default.aspx">Channel 9</category></item><item><title>Windows Vista Bridge Sample Library = A Managed API for Windows</title><link>http://blogs.msdn.com/yochay/archive/2008/11/14/windows-vista-bridge-sample-library-a-managed-api-for-windows.aspx</link><pubDate>Fri, 14 Nov 2008 03:41:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9068015</guid><dc:creator>yochayk</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/yochay/comments/9068015.aspx</comments><wfw:commentRss>http://blogs.msdn.com/yochay/commentrss.aspx?PostID=9068015</wfw:commentRss><description>&lt;P&gt;I am sure some of you are asking right now, “&lt;I&gt;Why are we writing and talking about Windows &lt;B&gt;Vista&lt;/B&gt; in the Windows 7® Blog for Developers?”&lt;/I&gt; The answer is simple. We are talking about &lt;A href="http://www.microsoft.com/windows/windows-vista/default.aspx" mce_href="http://www.microsoft.com/windows/windows-vista/default.aspx"&gt;Windows Vista&lt;/A&gt; because Windows 7 is based on the solid foundation of Windows Vista, and provides backward compatibility to the Windows Vista programming model. With that said, we are listening to customer feedback and making great improvements in regard to performance including better resource utilization, reliability, compatibility, and security, thereby perfecting the overall user experience while at the same time providing great value for developers. The &lt;A href="http://blogs.msdn.com/e7/archive/2008/08/27/windows-7-approach-to-system-performance.aspx" mce_href="http://blogs.msdn.com/e7/archive/2008/08/27/windows-7-approach-to-system-performance.aspx"&gt;Windows Engineering (E7) blog&lt;/A&gt; has a great post about this topic.&lt;/P&gt;
&lt;P&gt;It is no secret that the Windows Operating System (OS) is based on C / C++ and therefore uses a native programming model, most commonly known by its informal name &lt;B&gt;WinAPI&lt;/B&gt; or &lt;B&gt;Win32&lt;/B&gt; &lt;B&gt;API&lt;/B&gt;. The &lt;B&gt;Windows API&lt;/B&gt; is a &lt;U&gt;native C style or COM-based&lt;/U&gt; API. This makes using the API very easy and natural for native C /C++ developers. But what can we offer managed code developers? Are there any managed code APIs for Windows Vista or Windows 7? &lt;/P&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width=454&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=452&gt;The .NET Framework offers an easy and intuitive programming model targeting Windows clients (Web, servers, mobile, etc.) And, together with a set of tools and libraries, it provides a productive and effective framework for writing Windows client applications. One of the strengths of the .NET Framework is that it is a library-based framework, and anyone can add libraries to enhance the framework’s functionality. In fact, the out-of-the-box .NET experience offers a large number of libraries that abstracts the native Windows API, making development for a given Windows client (regardless of the OS version – XP, Vista, or 7) a much easier task than using the native Windows API.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;TABLE border=0 cellSpacing=0 cellPadding=2 width=453&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD vAlign=top width=200&gt;A good example is the .NET WinForms assembly (assembly is .NET’s name for libraries), which contains a set of wrapper classes that wrap a traditional Win 32 API for creating and handling windows in the Windows OS. By abstracting the native API, .NET WinForms ensures that we don’t need to directly work with pointers (HWND) or handles (HINSTANCE) or other Windows native API constructs that could result in code that looks like this:&lt;/TD&gt;
&lt;TD vAlign=top width=251&gt;
&lt;P align=center&gt;&lt;BR&gt;&lt;A href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_2.png" mce_href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_2.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; MARGIN: 0px 0px 0px 5px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb.png" width=244 height=216 mce_src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P&gt;Rest assured, WinForms is HWND based. A .NET developer can easily access a given Windows form Handle or (HWND) by using the MSG.hwnd property that can be found in the System.Windows.Interop class in the WindowsBase assembly (WindowsBase.dll).&lt;/P&gt;
&lt;P&gt;But as comprehensive as the .NET Framework is, it does not offer managed APIs to all Windows’ native APIs. For example, a managed code developer doesn’t have any managed APIs to work with Windows Vista User Account Control (UAC) API, Restart Manager API, or the new Windows Vista Search API. These are just few examples of &lt;B&gt;&lt;U&gt;key&lt;/U&gt;&lt;/B&gt; native Windows APIs that .NET Framework doesn’t provide interfaces to and yet are crucial for a given application to successfully deploy on Windows while bringing excitement and innovations to end users. &lt;/P&gt;
&lt;P&gt;The &lt;A href="http://code.msdn.microsoft.com/VistaBridge" mce_href="http://code.msdn.microsoft.com/VistaBridge"&gt;Windows Vista Bridge Sample Library&lt;/A&gt; (VBSL) is an ongoing effort by the Microsoft SDK team to bridge between the .NET framework and the native Windows API. The VBSL is a class library that makes it much easier for managed developers to access light-up Windows Vista features with no need to worry about the Interop layer. Vista Bridge 1.3 provides managed developers with a set of classes, libraries, and samples written in .NET that allows developers to take advantage of Vista features including UAC, Power Management, Restart &amp;amp; Recovery, Restart Manager, Network, Aero Glass, among many others. It is important to say that all the Vista Bridge managed libraries work well with Windows 7 APIs and will continue to work in future release as the SDK team will continue to support this project.&lt;/P&gt;
&lt;P&gt;The Vista Bridge Sample Library (&lt;A href="http://code.msdn.microsoft.com/VistaBridge" mce_href="http://code.msdn.microsoft.com/VistaBridge"&gt;download Vista Bridge Sample Library&lt;/A&gt;) is part of the &lt;A href="http://blogs.msdn.com/windowssdk/archive/2008/10/11/using-windows-sdk-vista-bridge-sample-library.aspx" mce_href="http://blogs.msdn.com/windowssdk/archive/2008/10/11/using-windows-sdk-vista-bridge-sample-library.aspx"&gt;Windows SDK&lt;/A&gt;. However, this project is important enough to be placed front center in the Code Gallery. &lt;/P&gt;
&lt;P&gt;In future posts, we will drill into a few of the features mentioned above, mainly to show how you can take advantage of Windows Vista today in order to make the migration path to Windows 7 much easier in the future. &lt;/P&gt;
&lt;P&gt;One area where the VBSL can make a big difference is in dialogs. &lt;/P&gt;
&lt;P&gt;Windows Vista offers a wide variety of dialog boxes for different purposes. For examples, if you are using Windows Vista I am sure you are familiar this UI format:&lt;/P&gt;
&lt;P&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb_1.png" width=244 height=192 mce_src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb_1.png"&gt;&lt;/P&gt;
&lt;P&gt;Or with this one:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_6.png" mce_href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_6.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb_2.png" width=244 height=157 mce_src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb_2.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Both of the above screenshots are fancy dialog boxes based on &lt;A href="http://msdn.microsoft.com/en-us/library/aa511455.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa511455.aspx"&gt;command links&lt;/A&gt;. With &lt;I&gt;command links&lt;/I&gt;, users select a single response to a main instruction and by doing so, move on to the next step in a task. Command links have a clean, lightweight appearance that allows for descriptive labels, and are displayed with either a standard arrow or custom icon, and an optional supplemental explanation.&lt;/P&gt;
&lt;P&gt;Here is an example of a typical set of command links.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_8.png" mce_href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_8.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb_3.png" width=465 height=294 mce_src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb_3.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Command links are similar to radio buttons in that they are used to select from a set of mutually exclusive, related choices. Like radio buttons, command links are always presented in sets, never individually. Command links have a lightweight appearance similar to regular links, without a frame or other strong click affordance. Command links are also similar to &lt;A href="http://msdn.microsoft.com/en-us/library/aa511453.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa511453.aspx"&gt;command buttons&lt;/A&gt;, in that they can be the default "command button" and they can have an access key assigned. Like &lt;A href="http://msdn.microsoft.com/en-us/library/aa511441.aspx" mce_href="http://msdn.microsoft.com/en-us/library/aa511441.aspx"&gt;commit buttons&lt;/A&gt;, when clicked they either close the window (for dialog boxes) or advance to the next page (for wizards and pages flows).&lt;/P&gt;
&lt;P&gt;Using the Windows Vista Bridge Sample Library, you can now create fancy Task Dialogs that look like this: &lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_9.png" mce_href="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_9.png"&gt;&lt;IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: block; FLOAT: none; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; MARGIN-LEFT: auto; BORDER-LEFT-WIDTH: 0px; MARGIN-RIGHT: auto" title=image border=0 alt=image src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb_4.png" width=376 height=312 mce_src="http://blogs.msdn.com/blogfiles/yochay/WindowsLiveWriter/WindowsVistaBridgeSampleLibraryAManagedA_E3E1/image_thumb_4.png"&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;The Task Dialog is an object in the Vista Bridge Sample Library, Microsoft.SDK.Samples.VistaBridge.Library.TaskDialog and has no design time properties; therefore, you must program the Dialog. But this is easy, as shown in the next examples.&lt;/P&gt;
&lt;P&gt;First, create a task dialog: TaskDialog td = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; TaskDialog();&lt;/P&gt;
&lt;P&gt;Then start setting its attributes, for example, caption, instructions, main content area, and the main icon: &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=rem&gt;//main content section&lt;/SPAN&gt;
td.Caption = &lt;SPAN class=str&gt;"Fancy \"Vista\" Task Dialog on Win 7"&lt;/SPAN&gt;;
td.Instruction = &lt;SPAN class=str&gt;"Your instructions go here"&lt;/SPAN&gt;;
td.Content = &lt;SPAN class=str&gt;"Download Windows Vista Bridge Library"&lt;/SPAN&gt;;
td.MainIcon = TaskDialogStandardIcon.Information;&lt;/PRE&gt;
&lt;P&gt;Now add the optional footer text and footer icon: 
&lt;STYLE type=text/css&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;
&lt;/P&gt;&lt;PRE class=csharpcode&gt;td.FooterText = &lt;SPAN class=str&gt;"Footer text goes here"&lt;/SPAN&gt;;
td.FooterIcon = TaskDialogStandardIcon.Shield;&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;





.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;

&lt;P&gt;But the fun starts when you start playing with the TaskDialog.Controls, a collection of (you guessed it) TaskDialog controls &lt;FONT color=#006080&gt;DialogControlCollection&lt;/FONT&gt;&amp;lt;&lt;FONT color=#006080&gt;TaskDialogControl&lt;/FONT&gt;&amp;gt;.&lt;/P&gt;
&lt;P&gt;To which you can add TaskDialogControl objects:&lt;/P&gt;&lt;PRE class=csharpcode&gt;td.Controls.Add(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; TaskDialogCommandLink(&lt;SPAN class=str&gt;"new tdcl"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"main text here"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"instruction"&lt;/SPAN&gt;));&lt;/PRE&gt;
&lt;P&gt;In addition to adding Command Links, the Task Dialog also exposes a set of events that lets you manipulate and interact with users as they operate the dialog. The Task Dialog object exposes the &lt;B&gt;Tick&lt;/B&gt; event to work with the progress bar, &lt;B&gt;Open&lt;/B&gt;, and &lt;B&gt;Closing&lt;/B&gt; events, as well as &lt;B&gt;HelpInvoked&lt;/B&gt; and &lt;B&gt;HyperLinkClick&lt;/B&gt; to manage user requests for more information and help. &lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=rem&gt;//events that you can catch&lt;/SPAN&gt;
td.Tick += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler&amp;lt;TaskDialogTickEventArgs&amp;gt;(OnMyTick);
td.Opened += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(OnOpenInvoked);
td.HelpInvoked += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(OnHelpInvoked);&lt;/PRE&gt;
&lt;P&gt;You can also add Progress Bar, CheckBox, or Radio Button. Basically, the Windows Vista Task Dialogs API is a mini Dialog framework that saves you a lot of time dealing with wizards and fancy dialog screens. &lt;/P&gt;
&lt;P&gt;Now it is up to you. Go ahead and &lt;A href="http://code.msdn.microsoft.com/VistaBridge" mce_href="http://code.msdn.microsoft.com/VistaBridge"&gt;download the Windows Vista Bridge Sample Library&lt;/A&gt;, and start using Vista styles dialog—they all work just as well on a Windows 7 machine.&lt;/P&gt;
&lt;P&gt;(This blog was written on a Windows 7 machine)&lt;/P&gt;
&lt;P&gt;J&lt;/P&gt;
&lt;P&gt;The code for the examples above&lt;/P&gt;
&lt;DIV class=csharpcode&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   1:  &lt;/SPAN&gt;td = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; TaskDialog();&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   2:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   3:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;//&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   4:  &lt;/SPAN&gt;td.StartupLocation = TaskDialogStartupLocation.CenterOwner;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   5:  &lt;/SPAN&gt;td.Cancelable = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   6:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   7:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;//main content section&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   8:  &lt;/SPAN&gt;td.Caption = &lt;SPAN class=str&gt;"Fancy \"Vista\" Task Dialog on Win 7"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;   9:  &lt;/SPAN&gt;td.Instruction = &lt;SPAN class=str&gt;"Your instructions go here"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  10:  &lt;/SPAN&gt;td.Content = &lt;SPAN class=str&gt;"Download Windows Vista Bridge Library Sample"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  11:  &lt;/SPAN&gt;td.MainIcon = TaskDialogStandardIcon.Information;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  12:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  13:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;//setting footer content&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  14:  &lt;/SPAN&gt;td.FooterText = &lt;SPAN class=str&gt;"Footer text goes here"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  15:  &lt;/SPAN&gt;td.FooterIcon = TaskDialogStandardIcon.Shield;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  16:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  17:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;//Command Links&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  18:  &lt;/SPAN&gt;td.Controls.Add(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; TaskDialogCommandLink(&lt;SPAN class=str&gt;"new tdcl"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"Main text here"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"Instruction"&lt;/SPAN&gt;));&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  19:  &lt;/SPAN&gt;td.Controls.Add(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; TaskDialogCommandLink&lt;/PRE&gt;&lt;PRE&gt;          (&lt;SPAN class=str&gt;"Another new tdcl"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;" Another main text here"&lt;/SPAN&gt;, &lt;SPAN class=str&gt;"More instruction"&lt;/SPAN&gt;));&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  20:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  21:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;//Expanding &lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  22:  &lt;/SPAN&gt;td.ExpansionMode = TaskDialogExpandedInformationLocation.ExpandContent;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  23:  &lt;/SPAN&gt;td.ExpandedControlText = &lt;SPAN class=str&gt;"Expanded Control Text"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  24:  &lt;/SPAN&gt;td.ExpandedText = &lt;SPAN class=str&gt;"This is some expanded text, only visible when expanded"&lt;/SPAN&gt;; &lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  25:  &lt;/SPAN&gt;td.CollapsedControlText = &lt;SPAN class=str&gt;"Collapsed Control Text"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  26:  &lt;/SPAN&gt;td.HyperlinksEnabled = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  27:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  28:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;//Prograss Bar&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  29:  &lt;/SPAN&gt;TaskDialogProgressBar tdpb = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; TaskDialogProgressBar();&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  30:  &lt;/SPAN&gt;tdpb.Name = &lt;SPAN class=str&gt;"myPrograssBar1"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  31:  &lt;/SPAN&gt;tdpb.Minimum = 0;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  32:  &lt;/SPAN&gt;tdpb.Maximum = 100;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  33:  &lt;/SPAN&gt;td.ProgressBar = tdpb; &lt;SPAN class=rem&gt;//adding to main Task Dialog&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  34:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  35:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;// Check Box&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  36:  &lt;/SPAN&gt;td.CheckBoxChecked = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  37:  &lt;/SPAN&gt;td.CheckBoxText = &lt;SPAN class=str&gt;"This is a checkbox, we can register to listen for its events"&lt;/SPAN&gt;;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  38:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  39:  &lt;/SPAN&gt;&lt;SPAN class=rem&gt;//events that you can catch&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  40:  &lt;/SPAN&gt;td.Tick += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler&amp;lt;TaskDialogTickEventArgs&amp;gt;(OnMyTick);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  41:  &lt;/SPAN&gt;td.Opened += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(OnOpenInvoked);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  42:  &lt;/SPAN&gt;td.HelpInvoked += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler(OnHelpInvoked);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  43:  &lt;/SPAN&gt;td.Closing += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler&amp;lt;TaskDialogClosingEventArgs&amp;gt;(OnDialogClosing);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  44:  &lt;/SPAN&gt;td.HyperlinkClick += &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; EventHandler&amp;lt;TaskDialogHyperlinkClickedEventArgs&amp;gt;(td_HyperlinkClick);&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  45:  &lt;/SPAN&gt;&amp;nbsp;&lt;/PRE&gt;&lt;PRE&gt;&lt;SPAN class=lnum&gt;  46:  &lt;/SPAN&gt;td.Show(); &lt;/PRE&gt;&lt;/DIV&gt;
&lt;STYLE type=text/css&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/STYLE&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9068015" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/yochay/archive/tags/Windows+7/default.aspx">Windows 7</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Developers/default.aspx">Developers</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Code+samples/default.aspx">Code samples</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Code+examples/default.aspx">Code examples</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Windows+Vista+Brdige+Sample+Library/default.aspx">Windows Vista Brdige Sample Library</category><category domain="http://blogs.msdn.com/yochay/archive/tags/Windows+Vista/default.aspx">Windows Vista</category></item></channel></rss>