<?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 examples</title><link>http://blogs.msdn.com/yochay/archive/tags/Code+examples/default.aspx</link><description>Tags: Code examples</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><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>