Search code examples
c#windows-7windows-xpthumbnailstaskbar

C# - mouse hover in taskbar, thumbnails preview is generated in window 7.


I am developing one application which shows thumbnails of running application on windows 7. Can i achieve the same thumbnail functionality on window XP.(If I run my application on XP) If Yes. Then How can i achieve this. Any idea? Thanks


Solution

  • In Windows 7 you can use the Desktop Window Manager (DWM) library (amongst other things) to take screenshots / thumnails. The documentation is part of the Win API but you can use them in C3 using platform invoke:

    [DllImport( "dwmapi.dll", PreserveSig = false )]
    public static extern void DwmRegisterThumbnail( IntPtr destinationWindowHandle, IntPtr sourceWindowHandle, out IntPtr thumbnailHandle );
    
    [DllImport( "dwmapi.dll", PreserveSig = false )]
    public static extern void DwmUnregisterThumbnail( IntPtr thumbnailHandle );
    
    [DllImport( "dwmapi.dll", PreserveSig = false )]
    public static extern void DwmUpdateThumbnailProperties( IntPtr thumbnailHandle, ref ThumbnailProperties properties );
    

    Finally, here is some sample code on how to implement the actual thumbnails.