A hosting environment for writing interactive system utilities. Source available in C# and VB. (MSDN Coding 4 Fun)
When you write small utilities, there’s a certain amount of tedious repetitive work to get it up and going. Creating the main window, the tray icon (including the icon and context menu), and other common tasks just get in the way. In this article, I’ve created
a reusable utility framework and will show you how to make use of it.
To run this code, you’ll need to use Visual Studio 2008 SP1, Express Edition or higher. If you haven’t downloaded it yet, go to
. You can either use Visual Basic or Visual C# to work with the main project or create add-ins for this project.
The codebase was modified pretty massively for version 2. It's now a multi-utility framework, more like the Sidebar. I still need to create a little more documentation for it, but the new article (to be published soon) will cover the basics. There's
also a sample addin in the v2 solution that can get you started. Read on for v1 information...
So what did I actually create for this article? We all know that using base classes is a great way to tie together closely-related objects. As a very practical example, a base window or control class lets you add functionality to something that already exists
without reinventing the wheel, so to speak. Windows exposes a number of code execution models such as services, console apps, Sidebar gadgets, Windows forms, WPF, COM, and more. Each of these provides a certain amount of functionality that you don’t need to
worry about, such as start/stop hooks for services, or the system message loop for Windows forms and WPF.
Having built a good number of small utilities over the years, I’ve definitely realized that I’m copying or rewriting too much code. What a waste! Since I always create a notification icon (shows up by the system clock), and I like to hide to tray on minimize,
and remember window settings, I implement these in each project. I probably should have created a project template in Visual Studio as a shortcut, but this has a disadvantage. If I added a cool new feature to my framework, I’d need to recompile and rework
the older apps to take advantage of it
The better solution was to create a “base application.” This would actually be its own application that exposes a notification icon and menu, and a main window. If you move the window, the location is saved. Individual utilities can then be added as plugins.
I originally envisioned a framework able to host multiple applications, but that creates some interesting design challenges with visual apps. In the end, I settled on a reusable application which can host a single utility.
on the Microsoft Coding 4 Fun site!