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 ‘Programming’ tag

A question I see raised often on forums is some variation on "how do I get menus that look like Vista's menus: icons with the baby-blue selection highlight." Or, how do I get my menus to look like Windows Explorer context menus:

Windows Explorer menu in Vista

The first thing you should notice is the light-blue gradient used for the selection highlight. The second thing is the alpha-blended icon (that is, the icon has partially transparent pixels that blend nicely with the light-blue gradient).

But how do you get that look without owner-drawing your menu items? There was a nice post over at Mircosoft's Shell Blog describing how to do it in C++. I've taken the applicable parts of the C++ code and ported them to a nice little interface for .NET languages. That is, you'll be able to use my code with C#, VB.NET, and any other .NET languages that exists.

Here's a screenshot of the interface I created (called VistaMenu) running in Windows Vista, Windows XP, and Windows 98:

VistaMenu on the InstantUpdate Designer

As you can see, I took the time to make sure the VistaMenu worked and looked good even in the older Windows systems.

How to use VistaMenu

You need to add ContextMenu, MainMenu, and VistaMenu controls to the Visual Studio toolbox:

  1. Download VistaMenu, and extract the zip archive somewhere on your computer.
  2. Right click the Toolbox and click 'Choose Items...'
  3. In the dialog that pops up, scroll down to 'ContextMenu' and click the check box.
  4. Also, scroll down even further to 'MainMenu' and click the check box.
  5. Now, press the 'Browse...' button and find the 'VistaMenu.dll' you downloaded and extracted earlier. Make sure it's checked in the list.
  6. Press 'OK' on the dialog box.

This should add all the necessary controls to the Toolbox. Now just drag the VistaMenu control to your form (you only need one VistaMenu per Form), a MainMenu, and any number of ContextMenus.

All you have to do now is click a menu items, and in the the Properties window select an Image. No messy ImageList is necessary:

Using VistaMenuYou should know...

As I mentioned parenthetically above, you only need one VistaMenu per form. This one VistaMenu component handles all the MenuItems for the MainMenu and all ContextMenus on your Form. If you add more than one 'VistaMenu' component you'll waste resources and your program will likely crash.

Also, VistaMenu is for ContextMenus and MainMenus, NOT ContextMenuStrips and MenuStrips. They're completely different controls.

Also out, SplitButton 2.0

Version 2.0 of the SplitButton adds support for ContextMenu in addition to ContextMenuStrip. Now you can use the shiny new VistaMenu with the SplitButton.

This is a breaking change, however. Previously you had to set the 'SplitMenu' property with a ContextMenuStrip, but in this version there are two properties: 'SplitMenu' and 'SplitMenuStrip'. Where 'SplitMenu' takes a ContextMenu, while 'SplitMenuStrip' takes a ContextMenuStrip.

Questions, comments, complaints...

Take a trip over to the forum and let me have it. No registration is required, and all input is welcome.

Download VistaMenu: Includes the source code, a compiled binary, and demo projects for both C# and VB.NET.

Download SplitButton v2.0: Includes the source code and the compiled binary. It works with every .NET language.

InstantUpdate 1.0 Release Candidate 2 is out now. This is a fairly large release; it has more bugs fixed and features added than any previous version.

New features:

  • InstantUpdate Client is now translated to 11 languages (Chinese, Dutch, French, German, Italian, Japanese, Korean, Portuguese, Russian, Spanish, and Swedish)
  • Create and edit translations using the new translation editor
  • InstantUpdate is now code signed which produces friendlier warnings when Vista's UAC elevation is needed
  • Appearance templates can be edited
  • Files can now be executed either before or after your update
  • Programs created with the .NET Framework are automatically optimized

Notable Bug fixes:

  • InstantUpdate Designer correctly supports Windows Explorer drag and drop.
  • Full support for custom set fonts, including Windows Vista's SegoeUI
  • InstantUpdate Designer starts and runs considerably faster
  • Keyboard accessibility improvements
  • Vista's UAC elevation is only called when absolutely necessary
  • Plus much more.

And, as always, the forum is open for questions, comments, bug reports, and general help of any kind. No registration is required, just drop by.

Download InstantUpdate 1.0 RC 2

Turtle day afternoon

In August I said "in about two weeks I'll upload the second release candidate [RC2]". What I meant was "in about two turtle weeks I'll upload the second release candidate." Well, it's nearing the end of the second turtle week and I still haven't found the conversion from whale-years to human-years. Thus, I have to release InstantUpdate 1.0 RC2 soon or risk being labeled a liar.

This release has a few new notable features like multi-lingual support, true drag-and-drop from Windows Explorer, editing and removing appearance templates, and the ability to preview the client without needing to run it on a test machine. More importantly, and subtly, RC2 went through an aesthetic overhaul.

I've used my time to make the interface simple. How? By eliminating all steps that can be done more efficiently by a computer. Go ahead, you can snigger at that sentence.

But Wyatt, a schizophrenic fragment of myself asks, isn't that the entire point of creating computer programs?

Good question, me. It is the whole point, but more specifically computer programs must allow freedom of creation while simultaneously restricting the user's actions. Don't scream "Orwellian" just yet. Although restricting liberties for the "greater good" sounds like something an authoritative government would say, in the case of computer programs it actually works.

For instance, this upcoming release fixes the way files and folders are handled. All previous versions of InstantUpdate gave the user complete control of how the files and folders in the update were visually organized:

File handling in RC2

As you can see, the "limited" control is much nicer. In addition to sorting sorts by name, I further limited the user's control by automatically warning you if you try to rename something to an invalid filename (by Windows standard) and prompts you if you try to overwrite an existing file or folder. Previously I just left all files and folder handling up to the user. It was an unnecessary freedom that led to messiness even in my own projects.

I could lie and say simplifying a program is hard. It's not; it's hours of tedium punctuated minutes of excitement and inspiration.

While you wait the remaining turtle days, here are a few screenshots which don't do justice to my work:

InsantUpdate RC2 start pageInstantUpdate RC2 multilingual supportInsantUpdate RC2 registry