# Function Reference

# _WinAPI_DwmRegisterThumbnail

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

#include <WinAPIGdi.au3>
_WinAPI_DwmRegisterThumbnail ( $hDestination, $hSource )

## Parameters

$hDestination | Handle to the window that will use the DWM thumbnail.
$hSource | Handle to the window to use as the thumbnail source.

## Return Value

Success: | Handle that represents the registration of the DWM thumbnail.
Failure: | 0 and sets the @error flag to non-zero, @extended flag may contain the HRESULT error code.

## Remarks

The window designated by $hDestination must either be the desktop window itself or be owned by the process that is calling _WinAPI_DwmRegisterThumbnail().
This function requires Windows Vista or later.

## See Also

Search DwmRegisterThumbnail in MSDN Library.

## Example

    #include <GUIConstantsEx.au3>
    #include <MsgBoxConstants.au3>
    #include <WinAPIGdi.au3>
    #include <WinAPIMisc.au3>

    If Not _WinAPI_DwmIsCompositionEnabled() Then
        MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
        Exit
    EndIf

    Run(@SystemDir & '\calc.exe')
    Local $hWnd = WinWaitActive("[CLASS:ApplicationFrameWindow]", '', 3)
    If Not $hWnd Then
        Exit
    EndIf

    ; Create GUI
    Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 400)

    GUISetBkColor(0)

    ; Create the "sheet of glass" effect for the entire window. You must call this function whenever DWM composition is toggled.
    _WinAPI_DwmExtendFrameIntoClientArea($hForm)

    ; Create a DWM thumbnail relationship (2:1)
    Local $hThumbnail = _WinAPI_DwmRegisterThumbnail($hForm, $hWnd)
    Local $tSIZE = _WinAPI_DwmQueryThumbnailSourceSize($hThumbnail)
    Local $iWidth = DllStructGetData($tSIZE, 1)
    Local $iHeight = DllStructGetData($tSIZE, 2)
    Local $tDestRect = _WinAPI_CreateRectEx((400 - $iWidth / 2) / 2, (400 - $iHeight / 2) / 2, $iWidth / 2, $iHeight / 2)
    Local $tSrcRect = _WinAPI_CreateRectEx(-20, -20, $iWidth + 40, $iHeight + 40)
    _WinAPI_DwmUpdateThumbnailProperties($hThumbnail, 1, 0, 255, $tDestRect, $tSrcRect)

    GUISetState(@SW_SHOW)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    WinClose("[CLASS:ApplicationFrameWindow]", "")