As we have already seen, Windows 7 has a convenient functionality for displaying preview application windows. If you hover the mouse over the window icon in the taskbar, you can see a reduced view of the window in seconds. This is very convenient when the user has a large number of windows open.
By default, these previews show the entire contents of the window. However, for some applications it would be much more convenient to show in the preview not the entire contents of the window, but only a part of it. This functionality is also provided for the Windows 7 taskbar and we can use it for our applications. Let's look at this feature in the Windows 7 taskbar.
')
As usual, we will use the .NET Interop Sample Library for this. As part of the wrappers for functions from the Windows system libraries, here is the SetThumbnailClip method, which will help us in implementing this functionality. When you call this method in the parameters, you must pass the current instance of the form and the coordinates bounding the window area.
private void Clip5_Click(object sender, EventArgs e)
{
WindowsFormsExtensions.SetThumbnailClip(this, new Rectangle(10, 10, 145, 145));
}
This example clearly shows that it is very easy to use this method.
Let's create a small application where we look at the possibilities of this functionality. To do this, I will create an empty application in which I will add a few more controls. After launching the application, the preview windows will look like this.
It can be seen that initially the preview displays the entire window. Let's limit the display area using the SetThumbnailClip method. Display, for example, only the input fields that are on the form.
What is interesting, if we have dynamic content on the form (for example, video), then it will be displayed in dynamics. In the demo application, I posted several animated images and displayed them within the preview. There is no need to do anything else for this.
What is important, in the process of the application, we can change the contents of the preview. For example, at some point in time we may need to display the contents of some important input field, and at another point to display an image from a form. Such dynamism can give the user the opportunity to receive relevant information for him.
Finally, if we need to display the entire contents of the form, we can use the same method, but pass the dimensions of the entire form to it. In this case, the preview will display the entire window again.
private void NoClip_Click(object sender, EventArgs e)
{
WindowsFormsExtensions.SetThumbnailClip(this, new Rectangle(new Point(0, 0), Size));
}
Demo application:
Taskbar-ThumbnailClip.zip