#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>

Local $hGUI, $hChild, $hWnd_Desktop
Local $hDC_Dest, $hDC_Source
Local $iX, $iY, $iW, $iH

; GUI erstellen, und Child GUI, das auf dem Haupt GUI liegt.
$hGUI = GUICreate("Main", 200, 200, 0, 0, Default, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW, $hGUI)

$hBorder = GUICreate("", 100, 100, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST), $hGUI)
GUICtrlSetBkColor(GUICtrlCreateLabel("", 0, 0, 100, 100, Default, $GUI_WS_EX_PARENTDRAG), 0xFF0000)
GUICtrlSetBkColor(GUICtrlCreateLabel("", 5, 5, 90, 90, Default, $GUI_WS_EX_PARENTDRAG), 0xABCDEF)
GUISetState()

_WinAPI_SetLayeredWindowAttributes($hBorder, 0xABCDEF, 255)


; Desktop und GUI DC holen.
$hWnd_Desktop = _WinAPI_GetDesktopWindow()
$hDC_Source = _WinAPI_GetDC($hWnd_Desktop)
$hDC_Dest = _WinAPI_GetDC($hGUI)


While GUIGetMsg() <> $GUI_EVENT_CLOSE

    ; Winposition abfragen
    $aWinPos = WinGetPos($hBorder)
    $iX = $aWinPos[0] ; x
    $iY = $aWinPos[1] ; y
    $iW = $aWinPos[2] ; width
    $iH = $aWinPos[3] ; height

    ; Bild per StretchBlt übertragen
    _WinAPI_StretchBlt( _
            $hDC_Dest, 0, 0, 200, 200, _
            $hDC_Source, $iX, $iY, $iW, $iH, _
            $SRCCOPY)
WEnd


Func _WinAPI_StretchBlt($hDestDC, $iXDest, $iYDest, $iWidthDest, $iHeightDest, $hSrcDC, $iXSrc, $iYSrc, $iWidthSrc, $iHeightSrc, $iRop)
    ; See _WinAPI_BitBlt
    Local $Ret = DllCall('gdi32.dll', 'int', 'StretchBlt', 'hwnd', $hDestDC, 'int', $iXDest, 'int', $iYDest, 'int', $iWidthDest, 'int', $iHeightDest, 'hwnd', $hSrcDC, 'int', $iXSrc, 'int', $iYSrc, 'int', $iWidthSrc, 'int', $iHeightSrc, 'dword', $iRop)
    If(@error) Or(Not IsArray($Ret)) Then
        Return SetError(1, 0, 0)
    EndIf
    Return 1
EndFunc   ;==>_WinAPI_StretchBlt
