The wyDay blog is where you find all the latest news and tips about our existing products and new products to come.

wyDay blog

Posts in the ‘windows 7’ tag

This will be the quickest tip youll 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 Microsofts own apps. See the ugly font in the window on the right:

On the left Im using the default system font in Windows Vista & 7: Segoe UI. On the right Im using the default font that every Windows Forms app uses: Microsoft Sans Serif. Its 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 & 7, since every other app in Vista & 7 uses the Segoe UI font.

Problem: Segoe UI isnt in Pre-Vista systems

The problem is that Segoe UI is only shipped with Vista & 7 versions of Windows. So you cant just hard-code the Font property of the form to be Segoe UI (or your app will look like utter crap in Windows 2000 & Windows XP).

And thus this simple snippet of code to use Segoe UI on Windows Vista & 7 while still using the default system font in Windows 98, 2000 & XP.

public Form1()
{
// use Segoe UI in Vista & 7
Font = SystemFonts.MessageBoxFont; InitializeComponent();
}

Or, in VB.NET:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' use Segoe UI in Vista & 7
Font = SystemFonts.MessageBoxFont
End Sub

Thats 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:

Bold font problem

What if you want to bold a title? Simple, right? Just click the Font property of the label you want to bold:

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.

In our case the parent is the Form and were explicitly setting the font to be bold for our label to be Bold Microsoft Sans Serif.

Ok, ok but how do I make a bold label use Segoe UI?

We just learned you wont be able to do it in the designer, so instead youll have to do it in code:

public Form1()
{
// use Segoe UI in Vista & 7
Font = SystemFonts.MessageBoxFont; InitializeComponent(); // set the title to be bold
lblTitle.Font = new Font(Font, FontStyle.Bold);
}

Or in VB.NET

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' use Segoe UI in Vista & 7
Font = SystemFonts.MessageBoxFont ' set the title to be bold
lblTitle.Font = New Font(Font, FontStyle.Bold)
End Sub

7 Days of Windows 7

Join me tomorrow when I talk about adding professional looking menus to your app. See the full list of articles in the series.

For the next 7 Days Ill be giving 7 C# & .NET tips to make your Windows application look like it was built for Vista and Windows 7. All of these tips are used in our products (wyBuild, wyUpdate, and LimeLM) and they range from the simple one-liner, free open source controls, and to the advanced tip.

And since wyBuild, wyUpdate, and LimeLM are all compatible with Windows 2000 through Windows 7 all of these tips will be backward compatible.

7 days of Windows 7

Day 1: Windows Vista & 7 Font, Segoe UI, in C# and VB.NET Day 2: Making the menus in your .NET app look professional Day 3: Windows 7 Progress Bar in .NET Day 4: Drag & drop icons in .NET Windows 2000, XP, Vista, and 7 Day 5: Shield icons, UAC, and process elevation in .NET on Windows 2000, XP, Vista, and 7 Day 6: Windows Vista and Windows 7 .NET Controls Every possible one you could ever want Day 7: Finishing touches: Make your .NET app shine with professionalism

Windows 7 will be available for download to MSDN and Technet subscriber in less than 2 weeks. I thought Id introduce a few controls to make Windows 7 development easier for C# and .NET programmers. The controls will be written for .NET 2.0 & Windows Forms, but will obviously be compatible with .NET 2.0, 3.0, 3.5 and the upcoming 4.0.

The first control I want to give you is a way to use the new progress bar in your apps taskbar icon. This is what the new taskbar progress bar looks like when Internet Explorer downloads a file:

Of course, what good is integrating this shiny new behavior into your apps if isnt backward compatible with Windows 2000, XP and Vista? None at all. And since this taskbar behavior is included in wyUpdate & wyBuild 2.2+, backwards compatibility is a must. Heres our Windows 7 Progress Bar running on Windows 2000 Windows 7:

Dont use the Taskbar Progress Bar

Like any new shiny piece of technology everyone wants to add it to their program. The flip side is that most of the times you shouldnt use it. Let me quote the Windows UX guide directly:


Is the progress feedback useful and relevant while using other programs? That is, are users likely to monitor the progress while using other programs, and change their behavior as a result? Such useful and relevant status is usually displayed using a modeless progress dialog box or a dedicated progress page, but not with a busy pointer, activity indicator, or progress bar on a status bar. If the status isn't useful when using other programs, just display the progress feedback directly in the program itself.

Correct:

Incorrect:

In the incorrect examples, the taskbar button progress bars aren't very useful.

Is the task continuous? If the task never completes, there's no need to show its progress. Examples of continuous tasks include antivirus scans and file indexing.

Incorrect:

In this example, a continuous task doesn't need to show progress.


By the way, the Windows User Experience Interaction Guidelines is a must read for all Windows Developers. Its a shit name (why not Windows Usability Guide?), but it has quite a few good tips. All I can ask is that you skim it once.

How we use the Taskbar progress bar in wyUpdate & wyBuild

Weve integrated the Windows 7 Taskbar progress bar in both wyBuild & wyUpdate. Heres wyBuild creating updates for Nero Burning ROM:

Heres wyUpdate installing an update:

Further Reading

Get Windows 7 Progress Bar Now

The latest version of the Windows 7 Progress Bar C# source code, example projects in VB.NET and C#, and binaries are available on the open source component page.

If you have any questions, or find any bugs you can report them in the comments or in the wyDay forum.