bright, fresh software
Downloads  |  Buy

Wyatt Says...

Posts Tagged ‘vb.net’

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:

On the left I’m using the default system font in Windows Vista & 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 & 7, since every other app in Vista & 7 uses the Segoe UI font.

Problem: Segoe UI isn’t in Pre-Vista systems

The problem is that Segoe UI is only shipped with Vista & 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 & 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

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:

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 we’re 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 won’t be able to do it in the designer, so instead you’ll 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 I’ll 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

After two years of writes and re-writes, I’m finally releasing InstantUpdate 1.0 Release Candidate. Aside from the heap of fixes, some of the notable features are:

  • Full Windows Vista compatibility
  • Overhauled designer and client interfaces
  • Uploading your updates within the designer
  • Entirely re-written update engine which includes, among other notable enhancements, restoring your software to the previous state (registry and files) if an error occurs or if the user cancels the update
  • Ability to update on non-administrator accounts

What are the system requirements?

The requirement for the both InstantUpdate Designer and Client is the .NET Framework 2.0. This is included with Windows Vista right out of the box, and is available for download on Windows Update for Windows 98, 2000, and XP. So, the ideal user of InstantUpdate is someone who programs in one of the .NET languages (C#, VB.NET, etc.) or someone who’s programming solely for Windows Vista.

Documentation and forum

Also, some documentation is now online – the content ranging from simple instructions on how to distribute the InstantUpdate client, to more advanced topics like the version numbering system used in the client. I will expand the help topics when I get closer to releasing the final version of InstantUpdate. If you have any questions, comments, bug reports, or otherwise, take advantage of the forum.

Speaking of the forum, you no longer need to register to post a message. I know how much of a pain in the ass it is to sign up for forums, so I removed the requirement altogether. Of course, if you do register in the forum you’ll have greater control over your posts (upload files, edit posts, etc.). But, like I said, it’s no longer a necessity.

I hope you enjoy using the release candidate of InstantUpdate.

Download InstantUpdate now.

Comment on InstantUpdate Release Candidate.