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.
BackgroundI implemented AppBar functionalities based on this article. Yet another article helped me to create a window with extended glass.
WndProc hookFor 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: IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam,
IntPtr lParam, ref bool handled)
{
return IntPtr.Zero;
}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: protected override void OnSourceInitialized(EventArgs e)
{
base.OnSourceInitialized(e); // Raising base method. IntPtr hwnd = new WindowInteropHelper(this).Handle; // Getting our window's handle.
HwndSource source = HwndSource.FromHwnd(hwnd);
source.AddHook(new HwndSourceHook(WndProc)); // Adding hook.
}The OnSourceInitialized method is raised when the window's handle is created. The Loaded event is called after this. Now we can receive the window's messages. Read more: Codeproject
QR: