Programming Windows 7: Taskbar. Part 7 - ThumbnailClip

    As we have already seen, Windows 7 has convenient functionality for displaying preview application windows. When you hover 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 display the entire contents of the window. However, for some applications it would be much more convenient to show in preview not all the contents of the window, but only part of it. Such functionality is also provided for the Windows 7 taskbar and we can use it for our applications. Let's look at this feature of the Windows 7 taskbar.



    As usual, we will use the .NET Interop Sample Library. 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 calling this method in the parameters, it is necessary to transfer the current instance of the form and the coordinates that bound the window area. This example clearly shows that using this method is very easy. Let's create a small application where we look at the capabilities of this functionality. To do this, I will create an empty application in which I will add several several controls. After launching the application, the preview window will look as follows.

    private void Clip5_Click(object sender, EventArgs e)
    {
    WindowsFormsExtensions.SetThumbnailClip(this, new Rectangle(10, 10, 145, 145));
    }








    It is seen that initially in the preview the entire window is displayed. Let's limit the display area using the SetThumbnailClip method. We 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 some animated images and displayed them as part of 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, it may be necessary for us to display the contents of some important input field, and at another point to display an image from the 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 again display the entire window. Sample Application: Taskbar-ThumbnailClip.zip

    private void NoClip_Click(object sender, EventArgs e)
    {
    WindowsFormsExtensions.SetThumbnailClip(this, new Rectangle(new Point(0, 0), Size));
    }




    Also popular now: