<?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; Microsoft</title>
	<atom:link href="http://wyday.com/blog/category/microsoft/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>Making the menus in your .NET app look professional</title>
		<link>http://wyday.com/blog/2009/making-the-menus-in-your-net-app-look-professional/</link>
		<comments>http://wyday.com/blog/2009/making-the-menus-in-your-net-app-look-professional/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 23:34:54 +0000</pubDate>
		<dc:creator>Wyatt O&#39;Day</dc:creator>
				<category><![CDATA[Asthetics]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></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=131</guid>
		<description><![CDATA[How to use Windows 7 styled menus in your .NET app.]]></description>
			<content:encoded><![CDATA[<p>Those of you who follow this blog regularly already know the tip I’m sharing today. It’s about the control I created a couple of years ago: <a href="http://wyday.com/vistamenu/">VistaMenu</a>.</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/making-the-menus-in-your-net-app-look-professional/win7cmenu.png" title="Windows 7 context Menu" class="aligncenter" width="206" height="255" /></p>
<p>Normally I would just show a menu from Windows 7 and say “this is how you do it”. Take the menu above, for example. It’s the context menu when you right click the desktop in Windows 7. It’s subtle and usable. It’s less about being visually appealing than it is about being usable.</p>
<p>I find Windows Vista and Windows 7 menus to be aesthetically pleasing. However, not everyone would agree.</p>
<h3>Aesthetics – ask 1000 people, get 1000 opinions</h3>
<p>How do you judge art? It’s damn near impossible to get 100% consensus. Luckily programs aren’t art – they have utility first and style second.</p>
<p>Or, put more simply, if the style detracts from usability it is bad style.</p>
<p>Here are a couple of examples of bad menus. The following menus are tacky for the simple reason that the styling adds no extras usability. The excessive gradients and bad backgrounds distracts from the purpose of the menus:</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/making-the-menus-in-your-net-app-look-professional/tacky.cmenus.png" title="Tacky menus" class="aligncenter" width="391" height="155" /></p>
<h3>Difference between MenuStrip and MainMenu</h3>
<p>If you’ve been programming with Windows Forms for any length of time, it’s very likely you already use MenuStrips and ContextMenuStrips. They are entirely custom-draw menus created by Microsoft and included in .NET Framework 2.0+.</p>
<p>However, the theme of the MenuStrip and ContextMenuStrip controls don&#8217;t automatically adjust to match the Windows 7 theme. But, as you can see below, the MainMenu and ContextMenu controls <em>do</em> match the Windows 7 theme.</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/making-the-menus-in-your-net-app-look-professional/menus.png" title="MainMenu vs. MenuStrip" class="aligncenter" width="292" height="315" /></p>
<p>You can add MainMenu &#038; ContextMenu to Visual Studio by right clicking the toolbox, clicking “Choose Items…” and checking the “MainMenu” and “ContextMenu” check boxes.</p>
<h3>Why you should always use MainMenu</h3>
<p>If all the discussion of aesthetics was lost on you, then you should always use MainMenu for two simple reasons:</p>
<ol>
<li>Your program will look like it fits in with all the other programs on your users’ computers</li>
<li>Microsoft does the hard work for you. That is, with each new version of Windows Microsoft subtly tweaks the menu to be more usable.</li>
</ol>
<p>The Menu<strong>Strip</strong> and ContextMenu<strong>Strip</strong> controls are written entirely in C# and will forever look as tacky as they do now. The MainMenu and ContextMenu, however, are simple wrappers around the Windows API. This means that whenever Microsoft updates the menu API in Windows you will get all the usability improvements without lifting a finger.</p>
<p>Look at the screenshot below and you can see how Microsoft even changed the menu API between Windows Vista and Windows 7. The borders are sharper, the colors are tweaked, and the gradient is toned down.</p>
<h3>Adding icons to MainMenu and ContextMenus</h3>
<p>Microsoft was good enough to add simple API for adding icons to menus. I wrote a .NET wrapper for this API a couple of years ago, <a href="http://wyday.com/vistamenu/">VistaMenu</a>. Enough chit-chat, here’s <a href="http://wyday.com/vistamenu/howtouse.php">how you use VistaMenu</a>. It’s open source and works with Windows 98 – Windows 7.</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/making-the-menus-in-your-net-app-look-professional/vistamenu-platforms.png" title="VistaMenu on Windows 2000 - Windows 7" class="aligncenter" width="500" height="575" /></p>
<h3>7 Days of Windows 7</h3>
<p>Join me tomorrow when I talk about Windows 7 progress bars. <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/making-the-menus-in-your-net-app-look-professional/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Windows Vista &amp; 7 Font, Segoe UI, in C# and VB.NET</title>
		<link>http://wyday.com/blog/2009/windows-vista-7-font-segoe-ui-in-windows-forms/</link>
		<comments>http://wyday.com/blog/2009/windows-vista-7-font-segoe-ui-in-windows-forms/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 22:35:16 +0000</pubDate>
		<dc:creator>Wyatt O&#39;Day</dc:creator>
				<category><![CDATA[Asthetics]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows Vista]]></category>
		<category><![CDATA[vb.net]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://wyday.com/blog/?p=130</guid>
		<description><![CDATA[Use Segoe UI font in your Windows Forms app. Sample code in C# and VB.NET.]]></description>
			<content:encoded><![CDATA[<p>This will be the quickest tip you’ll ever read. But first, some background. If run your .NET app on Windows Vista or Windows 7 unaltered you might notice the fonts look a little funky. Especially when compared to Microsoft’s own apps. See the ugly font in the window on the right:</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/vista-7-font/segoeui-compare.png" title="SegoeUI comparison" class="aligncenter" width="614" height="340" /></p>
<p>On the left I’m using the default system font in Windows Vista &#038; 7: Segoe UI. On the right I’m using the default font that every Windows Forms app uses: Microsoft Sans Serif. It’s quite obvious that the Segoe UI font is slightly larger and more legible. Not only that, but if you use the font on the right instead – the Microsoft Sans Serif – your app will be out of place in Windows Vista &#038; 7, since every other app in Vista &#038; 7 uses the Segoe UI font.</p>
<h3>Problem: Segoe UI isn’t in Pre-Vista systems</h3>
<p>The problem is that Segoe UI is only shipped with Vista &#038; 7 versions of Windows. So you can’t just hard-code the Font property of the form to be Segoe UI (or your app will look like utter crap in Windows 2000 &#038; Windows XP).</p>
<p>And thus this simple snippet of code to use Segoe UI on Windows Vista &#038; 7 while still using the default system font in Windows 98, 2000 &#038; XP.</p>
<pre>
public Form1()
{
    // use Segoe UI in Vista &#038; 7
    Font = SystemFonts.MessageBoxFont;

    InitializeComponent();
}
</pre>
<p>Or, in VB.NET:</p>
<pre>
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' use Segoe UI in Vista &#038; 7
    Font = SystemFonts.MessageBoxFont
End Sub
</pre>
<p>That’s all you have to do to use Segoe UI font in your app. And if you set the AutoScaleMode of the form to “Font” then all of the controls on the form will scale to fit the larger font:</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/vista-7-font/asmode.png" title="AutoScaleMode set to Font" class="aligncenter" width="344" height="187" /></p>
<h3>Bold font problem</h3>
<p>What if you want to bold a title? Simple, right? Just click the Font property of the label you want to bold:</p>
<p><img alt="" src="http://img.wyday.com/blog/images/2009/vista-7-font/fontdiag.png" title="Font Dialog" class="aligncenter" width="340" height="276" /></p>
<p>However, the problem with doing this is now every control on the form except the label you want to bold will be Segoe UI font. Why is this? Every control on your form will have the same font as the parent unless specified otherwise.</p>
<p>In our case the parent is the Form and we’re explicitly setting the font to be bold for our label to be “Bold Microsoft Sans Serif”.</p>
<h3>“Ok, ok – but how do I make a bold label use Segoe UI?”</h3>
<p>We just learned you won’t be able to do it in the designer, so instead you’ll have to do it in code:</p>
<pre>
public Form1()
{
    // use Segoe UI in Vista &#038; 7
    Font = SystemFonts.MessageBoxFont;

    InitializeComponent();

    // set the title to be bold
    lblTitle.Font = new Font(Font, FontStyle.Bold);
}
</pre>
<p>Or in VB.NET</p>
<pre>
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' use Segoe UI in Vista &#038; 7
    Font = SystemFonts.MessageBoxFont

    ' set the title to be bold
    lblTitle.Font = New Font(Font, FontStyle.Bold)
End Sub
</pre>
<h3>7 Days of Windows 7</h3>
<p>Join me tomorrow when I talk about adding professional looking menus to your app. <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-vista-7-font-segoe-ui-in-windows-forms/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>LinkLabel with the correct Hand Cursor</title>
		<link>http://wyday.com/blog/2008/linklabel-with-the-correct-hand-cursor/</link>
		<comments>http://wyday.com/blog/2008/linklabel-with-the-correct-hand-cursor/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 05:01:36 +0000</pubDate>
		<dc:creator>Wyatt O&#39;Day</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[linklabel]]></category>
		<category><![CDATA[linklabel2]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://wyday.com/blog/?p=106</guid>
		<description><![CDATA[If you've done any Windows Forms designing then you've undoubtedly used the LinkLabel control. You've also likely noticed its hideous look. Read on for fixes for the ugly Hand cursor and bad font rendering.]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve done any Windows Forms designing then you&#8217;ve undoubtedly used the LinkLabel control. You&#8217;ve also likely noticed its hideous look:</p>
<p><img class="aligncenter" title="LinkLabel vs. LinkLabel2 Hand cursor" src="http://wyday.com/blog/images/2008/linklabel-with-the-correct-hand-cursor/hand-cursor-comparison.png" alt="" width="342" height="223" /></p>
<p>The ugliness of the LinkLabel that ships with Windows Forms is four fold.</p>
<ol>
<li>The repulsive navy blue color reminds me of Netscape Navigator (anyone else remember the graceful “Illegal Operation” crashes?).</li>
<li>There&#8217;s no hover effect. OK, I lied. There&#8217;s a hover effect but you have to code it. And if you do code it, you better put on your epilepsy goggles – it&#8217;s gonna flicker.</li>
<li>The non-standard hand cursor is missing the shadow and the gradient.</li>
<li>The LinkLabel font is oddly rendered:</li>
</ol>
<p><img class="aligncenter" title="Font rendering in LinkLabel vs. LinkLabel2" src="http://wyday.com/blog/images/2008/linklabel-with-the-correct-hand-cursor/font-rendering-comparison.png" alt="" width="375" height="140" /></p>
<p>The Windows.Forms LinkLabel looks as though the text was drawn to the screen once, then drawn again without erasing the first copy. This gives the LinkLabel a jagged, “blocky” look.</p>
<h3>LinkLabel2 &#8211; How I fixed it</h3>
<p>It was a simple bit of code. I used &#8216;TextRenderer.DrawText(&#8230;)&#8217; to do the actual drawing. The hand cursor was simply a matter of intercepting the WM_SETCURSOR message to my LinkLabel2 control:</p>
<pre>
[DllImport("user32.dll")]
public static extern int LoadCursor(int hInstance, int lpCursorName);

[DllImport("user32.dll")]
public static extern int SetCursor(int hCursor);

protected override void WndProc(ref Message m)
{
    //WM_SETCURSOR == 32
    if (m.Msg == 32)
    {
        //IDC_HAND == 32649
        SetCursor(LoadCursor(0, 32649));

        //the message has been handled
        m.Result = IntPtr.Zero;
        return;
    }

    base.WndProc(ref m);
}
</pre>
<h3>But what about SysLink?</h3>
<p><a href="http://msdn.microsoft.com/en-us/library/bb760704%28VS.85%29.aspx">SysLink</a> is a link control added to “ComCtl32.dll” in Windows XP. So, why not use SysLink? Because SysLink doesn&#8217;t exist in Windows 2000/98.</p>
<p>Maybe in 3 years, when Windows 2000 is dead, a simple SysLink wrapper for C# can be written.</p>
<h3>Get it</h3>
<p>It works with all the .NET 2.0 + languages (C#, VB.NET, etc.).</p>
<div class="download_button"><a title="Download LinkLabel2 now" href="http://wyday.com/files/LinkLabel2.zip">Download LinkLabel2 now</a></div>
<p>Also while you&#8217;re at it download <a href="http://wyday.com/wyupdate/">wyUpdate</a>, or any of my <a href="http://wyday.com/opensource.php">other open source projects</a>. </p>
<p><a href="http://wyday.com/linklabel2/">Go to the LinkLabel2 site</a> for further updates.</p>
]]></content:encoded>
			<wfw:commentRss>http://wyday.com/blog/2008/linklabel-with-the-correct-hand-cursor/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
