DwmRegisterThumbnail function

Creates a Desktop Window Manager (DWM) thumbnail relationship between the destination and source windows.

Syntax

DWMAPI DwmRegisterThumbnail(
  HWND        hwndDestination,
  HWND        hwndSource,
  PHTHUMBNAIL phThumbnailId
);

Parameters

hwndDestination

The handle to the window that will use the DWM thumbnail. Setting the destination window handle to anything other than a top-level window type will result in a return value of E_INVALIDARG.

hwndSource

The handle to the window to use as the thumbnail source. Setting the source window handle to anything other than a top-level window type will result in a return value of E_INVALIDARG.

phThumbnailId

A pointer to a handle that, when this function returns successfully, represents the registration of the DWM thumbnail.

Return Value

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Registering a DWM thumbnail relationship will not modify desktop composition; for information about thumbnail positioning, see the documentation for the DwmUpdateThumbnailProperties function.

The window designated by hwndDestination must either be the desktop window itself or be owned by the process that is calling DwmRegisterThumbnail. This is required to prevent applications from affecting the content of other applications.

The thumbnail registration handle obtained by this function is not globally unique but is unique to the process. Call the DwmUnregisterThumbnail function to unregister the thumbnail. This must be done within the process that the relationship was registered in.

Examples

The following example demonstrates how to register the desktop thumbnail.

C++
HRESULT UpdateDesktop(HWND hwnd)
{
	HRESULT hr = S_OK;
// Register the thumbnail
HTHUMBNAIL thumbnail = NULL;

hr = DwmRegisterThumbnail(hwnd, FindWindow(_T("Progman"), NULL), &thumbnail);
if (SUCCEEDED(hr))
{
	// Display the thumbnail using DwmUpdateThumbnailProperties
}
return hr;	

}

Requirements

   
Windows version Windows Vista [desktop apps only] Windows Server 2008 [desktop apps only]
Target Platform Windows
Header dwmapi.h
Library Dwmapi.lib
DLL Dwmapi.dll

See Also

DWM Thumbnail Overview

Desktop Window Manager Overview

DwmQueryThumbnailSourceSize

DwmUnregisterThumbnail

DwmUpdateThumbnailProperties