<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wyatt Says... &#187; Windows Vista</title>
	<atom:link href="http://wyday.com/blog/category/vista/feed/" rel="self" type="application/rss+xml" />
	<link>http://wyday.com/blog</link>
	<description>Design articles to make your users deliriously happy</description>
	<lastBuildDate>Sat, 03 Jul 2010 07:18:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Finishing touches: Make your .NET app shine with professionalism</title>
		<link>http://wyday.com/blog/2009/finishing-touches-make-your-net-app-shine-with-professionalism/</link>
		<comments>http://wyday.com/blog/2009/finishing-touches-make-your-net-app-shine-with-professionalism/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 07:53:22 +0000</pubDate>
		<dc:creator>Wyatt O&#39;Day</dc:creator>
				<category><![CDATA[Asthetics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows Vista]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://wyday.com/blog/?p=139</guid>
		<description><![CDATA[Another easy tip to round out the series in 7 Days of Windows 7.]]></description>
			<content:encoded><![CDATA[<p>This is another easy tip to wrap up this series of articles.</p>
<h3>Keyboard accessibility</h3>
<p>Start your application and unplug your mouse. Can you navigate and use your application? If you hit the tab key does the next logical control get focused? Can you open the file menu by pressing Alt-F?</p>
<h4>Set tab ordering</h4>
<p>Simply set the “TabIndex” property of your controls in ascending starting with 0. This way when your users press the tab key they next focused control is the next control in the flow of your form.</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/7d7-polish/taborder.png" title="Tab ordering" class="aligncenter" width="281" height="229" /></p>
<h4>Menu quick keys</h4>
<p>To add “quick key” ability to your menus you just need to put an ampersand (“&#038;”) before the letter that will be used for quick access. For example, instead of a menu item captioned “File”, caption it “&#038;File” instead. Now your users can access that menu quickly by pressing Alt-F.</p>
<h3>SystemStyle Buttons, Radio Buttons, and Checkboxes</h3>
<p>In Windows Vista Microsoft changed the buttons, radio buttons, and checkboxes to have subtle animations. When you hover, check, and click these controls they all yield organic animations. But if you built your app using Windows Forms the subtle animations aren’t there.</p>
<p>To add these animations all you have to do is set the “FlatStyle” of these controls to “System”.</p>
<h3>Windows UX Guide</h3>
<p>Microsoft has assembled a great collection of <a href="http://msdn.microsoft.com/en-us/library/aa511258(loband).aspx">guidelines for designing applications</a>. It’s filled with screenshot examples showing good &#038; bad designs. Plus it’s surprising self deprecating – some of their examples of bad design are screenshots taken directly from Microsoft apps.</p>
<p>You should skim the guide at least once and bookmark it for later.</p>
<h3>7 Days of Windows 7</h3>
<p>That’s it for the series. If you missed the earlier articles you can <a href="http://wyday.com/blog/2009/7-days-of-windows-7-csharp-and-vb-net-tips/">see the full list of articles in the series</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://wyday.com/blog/2009/finishing-touches-make-your-net-app-shine-with-professionalism/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Shield icons, UAC, and process elevation in .NET on Windows 2000, XP, Vista, and 7</title>
		<link>http://wyday.com/blog/2009/using-shield-icons-uac-and-process-elevation-in-csharp-vb-net-on-windows-2000-xp-vista-and-7/</link>
		<comments>http://wyday.com/blog/2009/using-shield-icons-uac-and-process-elevation-in-csharp-vb-net-on-windows-2000-xp-vista-and-7/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 04:46:02 +0000</pubDate>
		<dc:creator>Wyatt O&#39;Day</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows Vista]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://wyday.com/blog/?p=137</guid>
		<description><![CDATA[A quick &#038; easy tutorial to using Shield icons, UAC, and process elevation in C# and VB.NET. The code works on Windows 2000, XP, Vista, and Windows 7.]]></description>
			<content:encoded><![CDATA[<p>One of the great things about Vista and Windows 7 is the user isolation. Even admin users need to “elevate” their account to make system changes. Take this Date and Time dialog from Windows 7 as an example:</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/7d7-uac/date.uac.png" title="Date and time in Windows 7" class="aligncenter" width="347" height="360" /></p>
<p>Every user can view the Date and time, but only administrators can change it.</p>
<h3>Adding this ability to your .NET application</h3>
<p>Although this series of articles is called “7 days of Windows 7” this particular article is applicable to Windows 2000 – Windows 7.</p>
<h4>Step 1. Do we have permission?</h4>
<p>The first step is to check if we can write to system registry or system files &#038; folders. There are many ways to do this, but the easiest method is a simple Windows API call:</p>
<pre>
// check if user is an admin for Windows 2000 and above
[DllImport("shell32.dll", EntryPoint = "#680", CharSet = CharSet.Unicode)]
public static extern bool IsUserAnAdmin();
</pre>
<p>This will return false if you’re a limited user on Windows 2000 – Windows 7, and will also return false if you are an admin but aren’t elevated on Windows Vista and Windows 7.</p>
<p>In other words, it will return false if you don’t have permission to access system files &#038; registry. And &#8216; IsUserAnAdmin” returns true if you do have permission.</p>
<h4>Step 2. Notifying the user that elevation will happen: UAC Shield Icon</h4>
<p>To set the shield icon to one of your buttons you have to do a few things. First, set the FlatStyle of your button to “System”:</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/7d7-uac/button.flatstyle.png" title="FlatStyle system" class="aligncenter" width="312" height="101" /></p>
<p>Next, you need to define a couple of functions:</p>
<pre>
public static bool AtLeastVista()
{
    return (Environment.OSVersion.Platform == PlatformID.Win32NT &#038;&#038; Environment.OSVersion.Version.Major >= 6);
}

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr SendMessage(HandleRef hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

public static void SetButtonShield(Button btn, bool showShield)
{
    //Note: make sure the button FlatStyle = FlatStyle.System
    // BCM_SETSHIELD = 0x0000160C
    SendMessage(new HandleRef(btn, btn.Handle), 0x160C, IntPtr.Zero, showShield ? new IntPtr(1) : IntPtr.Zero);
}
</pre>
<p>Now, simply use this snippet in your code:</p>
<pre>
…
// UAC Shield on next button for Windows Vista+
if (AtLeastVista())
    SetButtonShield(btnName, true);
…
</pre>
<h4>Step 3. Re-launching process with administrator privileges</h4>
<p>All we have to do now is show the elevation dialog and elevate the current program. You might want to specify some arguments, but the barebones of it is as follows:</p>
<pre>
ProcessStartInfo psi = new ProcessStartInfo
                           {
                               Arguments = "-justelevated",
                               ErrorDialog = true,

                               // Handle is the handle for your form
                               ErrorDialogParentHandle = Handle,
                               FileName = Application.ExecutablePath,
                               Verb = "runas"
                           };
try
{
    Process.Start(psi);
    Close();
}
catch (Exception ex)
{
    // the process couldn't be started. This happens for 1 of 3 reasons:

    // 1. The user cancelled the UAC box
    // 2. The limited user tried to elevate to an Admin that has a blank password
    // 3. The limited user tries to elevate as a Guest account
    MessageBox.Show(ex.Message);
}
</pre>
<h4>Step 4. Code signing</h4>
<p>Chances are that if you try to elevate your application you’ll get an ugly yellow elevation box:</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/7d7-uac/codesigned-compare.png" title="wyUpdate UAC on Vista" class="aligncenter" width="665" height="342" /><br />
<img alt="" src="http://img.wyday.com/blog/images/2009/7d7-uac/codesigned-compare-7.png" title="wyUpdate UAC on Windows 7" class="aligncenter" width="665" height="258" /></p>
<p>To get the nice UAC box you’ll need to <a href="http://en.wikipedia.org/wiki/Code_signing" rel="nofollow">code sign</a> your application. I won’t link to any code signing providers (because the list is huge), but you can get a code signing certificate from anywhere between $100 for 3 years to $400 or $500 for a single year. It depends on the company you use and the amount of searching you want to do.</p>
<h3>7 Days of Windows 7</h3>
<p>Join me tomorrow when I talk about Every possible Windows Vista and Windows 7 .NET Control You could ever want. <a href="http://wyday.com/blog/2009/7-days-of-windows-7-csharp-and-vb-net-tips/">See the full list of articles in the series</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://wyday.com/blog/2009/using-shield-icons-uac-and-process-elevation-in-csharp-vb-net-on-windows-2000-xp-vista-and-7/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Windows 7 Progress Bars in .NET</title>
		<link>http://wyday.com/blog/2009/windows-7-progress-bars-dot-net/</link>
		<comments>http://wyday.com/blog/2009/windows-7-progress-bars-dot-net/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 01:26:35 +0000</pubDate>
		<dc:creator>Wyatt O&#39;Day</dc:creator>
				<category><![CDATA[Asthetics]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows Vista]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://wyday.com/blog/?p=132</guid>
		<description><![CDATA[Add Windows 7 style progress bars to your app with just a touch of Windows API. Or download the full open source component.]]></description>
			<content:encoded><![CDATA[<p>This will be another easy tip because all the work is already done and wrapped up in a nice little control. It’s open source and handles all of the details, <a href="http://wyday.com/windows-7-progress-bar/">get it here</a>.</p>
<p>Progress bars in Windows 7 are nearly identical to what they were in Windows Vista. They’re green, animated and have 3 states: Normal, Error, and Paused:</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/windows-7-progress-bars/states.png" title="Windows Vista &#038; 7 PB States" class="aligncenter" width="225" height="101" /></p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/windows-7-progress-bars/ie.tb.png" title="Taskbar progress bar" class="aligncenter" width="300" height="281" /></p>
<h3>Using Windows API</h3>
<p>To get both the 3-state progress bar (regular, error, and paused) along with the taskbar progress bar we need to use some Windows API. The easier of the two to implement is changing the state of the progress bar. This works on Windows Vista and Windows 7:</p>
<pre>
[DllImport("user32.dll", CharSet = CharSet.Auto)]
internal static extern int SendMessage(IntPtr hWnd, int wMsg, int wParam, int lParam);

SetPaused()
{
    // 0x410 = PBM_SETSTATE
    // 0x0003 = PBST_PAUSE
    SendMessage(progressBar.Handle, 0x410, 0x0003, 0);
}

SetError()
{
    // 0x0002 = PBST_ERROR
    SendMessage(progressBar.Handle, 0x410, 0x0002, 0);
}

SetNormal()
{
    // 0x0001 = PBST_NORMAL
    SendMessage(progressBar.Handle, 0x410, 0x0001, 0);
}
</pre>
<p>Then there’s the matter of the taskbar progress bar in Windows 7. You can <a href="http://wyday.com/files/Windows7ProgressBar.zip">download the Windows7ProgressBar source code</a> (zip file) to see how I did it, but the gist of it is you need to implement the <a href="http://msdn.microsoft.com/en-us/library/dd391692(VS.85).aspx">ITakbarList3 Interface</a>, and then use  the <a href="http://msdn.microsoft.com/en-us/library/dd391697(VS.85).aspx">SetProgressState</a> to set the state (Normal, Error, Paused, or Marquee) and <a href="http://msdn.microsoft.com/en-us/library/dd391698(VS.85).aspx">SetProgressValue</a> to set the value.</p>
<h3>7 Days of Windows 7</h3>
<p>Join me Monday when I talk about Drag &#038; Drop icons. <a href="http://wyday.com/blog/2009/7-days-of-windows-7-csharp-and-vb-net-tips/">See the full list of articles in the series</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://wyday.com/blog/2009/windows-7-progress-bars-dot-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
