Introduction

Google Desktop docks to the left or right edge of the screen and displays some gadgets. It is always visible. It does not cover other windows, and other windows do not hide it. To do that, we have to use the AppBar - the taskbar is an AppBar too. This article explains how to create an application like Google Desktop in WPF.

Background

I implemented AppBar functionalities based on this article. Yet another article helped me to create a window with extended glass.

WndProc hook

For some functions in this project, we must receive window messages. In Windows Forms, it is sufficient to override the WndProc function, but in WPF, we must add a hook. First, we create a callback for the hook:

hwnd is the handle to the window, msg is the ID of the window message, wParam and lParam are message parameters. If we process a message, we have to set handled to true. The WndProc does not receive messages, because we haven't added a hook. So add a hook using the following code:

Now go to Project Properties and to the Settings tab. Add the uEdge property. It must be of type int. uEdge is the screen's edge to which the AppBar will be docked. Set it to 2 (right edge) or 0 (left edge).

Let's now write the functions for registering and unregistering the AppBar.

Extending glass

This feature requires Windows Vista or higher. When Aero (DWM) composition is enabled, the caption and borders of the window are translucent, like glass. We can extend the glass effect into the client area. To do that, we need P/Invoke.

Notes gadget

Let's create the notes gadget. Add a new setting notes of type string. In this setting, we will save notes. Now add a new class and name it Notes. Add these references:

using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using System.Windows.Interop;

Conclusion

With the AppBar API, we can create applications like Google Desktop. DWM functions allow to use Aero effects, but they don't work in systems older than Windows Vista. In order to use WndProc in WPF, we must add a hook. In order to get the AppBar API, DWM API, and other cool stuff, we must use P/Invoke, because .NET doesn't have managed libraries to do that.