Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include-once
- #include <WinAPIConstants.au3>
- Global Const $DWM_TNP_RECTDESTINATION = 0x00000001
- ;~ Global Const $DWM_TNP_RECTSOURCE = 0x00000002
- Global Const $DWM_TNP_OPACITY = 0x00000004
- Global Const $DWM_TNP_VISIBLE = 0x00000008
- Global Const $DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010
- HotKeySet('{ESC}',Exit1)
- Func Exit1()
- Exit
- EndFunc
- $targetGUI = HWnd(0x000000000002004C)
- $hGUI1 = GUICreate('Preview 1',400,400)
- GUISetState(@SW_SHOW,$hGUI1)
- $handle1 = RegisterWindowLivePreview($targetGUI,$hGUI1)
- $hGUI2 = GUICreate('Preview 2',400,400)
- GUISetState(@SW_SHOW,$hGUI2)
- $handle2 = RegisterWindowLivePreview($targetGUI,$hGUI2)
- While 1
- Sleep(100)
- WEnd
- Func RegisterWindowLivePreview($hWindow,$hLivePreviewGui, $iClientAreaOnly = False, $iLivePreviewWidth = Default, $iLivePreviewHeight = Default, _
- $iLivePreviewRectX = 0, $iLivePreviewRectY = 0)
- If $iLivePreviewWidth = Default Or $iLivePreviewHeight = Default Then
- Local $aPos = WinGetPos($hLivePreviewGui)
- If @error Then
- ConsoleWrite("Can't get size of the GUI where the live preview will be draw." & @CRLF)
- Return SetError(1)
- EndIf
- If $iLivePreviewWidth = Default Then $iLivePreviewWidth = $aPos[2]
- If $iLivePreviewHeight = Default Then $iLivePreviewHeight = $aPos[3]
- EndIf
- Local $hDwmLivePreviewHandle = _DWM_Thumbnail_Register($hLivePreviewGui, $hWindow)
- If @error Then
- ConsoleWrite("Registration of Thumbnail failed." & @CRLF)
- Return SetError(2)
- EndIf
- ConsoleWrite($hDwmLivePreviewHandle & @CRLF)
- If Not _DwmQueryThumbnailSourceSize($hDwmLivePreviewHandle) Then
- ConsoleWrite("Thumbnail Source Size could not be determined." & @CRLF)
- _DWM_Thumbnail_Unregister($hDwmLivePreviewHandle)
- Return SetError(3)
- EndIf
- _DWM_Thumbnail_Update_Properties($hDwmLivePreviewHandle, $iLivePreviewRectX, $iLivePreviewRectY, $iLivePreviewWidth, $iLivePreviewHeight)
- If @error Then
- ConsoleWrite("Failed to _DWM_Thumbnail_Update_Properties" & @CRLF)
- _DWM_Thumbnail_Unregister($hDwmLivePreviewHandle)
- Return SetError(4)
- EndIf
- Return $hDwmLivePreviewHandle
- EndFunc
- Func _DWM_Thumbnail_Register($hwnd, $hWndOw)
- $tID = DllStructCreate('dword')
- $aRet = DllCall("dwmapi.dll", "int", "DwmRegisterThumbnail", "hwnd", $hwnd, "hwnd", $hWndOw, "ptr*", DllStructGetPtr($tID))
- If Not IsArray($aRet) Then
- Return SetError(1, 0, 0) ; Register thumbnail failed
- EndIf
- Return $aRet[3]
- EndFunc ;==>_DWM_Thumbnail_Register
- Func _DwmQueryThumbnailSourceSize($hThumbID)
- #cs
- http://msdn.microsoft.com/en-us/library/aa969520%28VS.85%29.aspx
- HRESULT DwmQueryThumbnailSourceSize(
- HTHUMBNAIL hThumbnail,
- PSIZE pSize
- );
- typedef struct tagSIZE {
- LONG cx;
- LONG cy;
- }SIZE, *PSIZE;
- #ce
- $tSize = DllStructCreate("int X;int Y")
- $aRet = DllCall("dwmapi.dll", "hwnd", "DwmQueryThumbnailSourceSize", "hwnd", $hThumbID, "ptr", DllStructGetPtr($tSize))
- If IsArray($aRet) And $aRet[0] = $S_OK Then
- $i_hwnd_Thumbnail_Width = DllStructGetData($tSize, 1)
- $i_hwnd_Thumbnail_Height = DllStructGetData($tSize, 2)
- Return True
- Else
- ;~ if Not IsArray($aRet) Then
- ;~ _FileWriteLog('WindowTopLog.log', "DwmAPI.au3 - L45 - _DwmQueryThumbnailSourceSize - $aRet is not array - return false")
- ;~ Else
- ;~ _FileWriteLog('WindowTopLog.log', "DwmAPI.au3 - L47 - _DwmQueryThumbnailSourceSize - $aRet[0] = " & $aRet[0])
- ;~ EndIf
- Return False
- EndIf
- EndFunc ;==>_DwmQueryThumbnailSourceSize
- Func _DWM_Thumbnail_Update_Properties($hThumbID, $rcDest_X, $rcDest_Y, $rcDest_Width, $rcDest_Height, $rcOpacity = 255, $rcReadOnly = True, $rcClientAreaOnly = 0)
- $tDWM_THUMBNAIL_PROPERTIES = DllStructCreate("dword dwFlags;int rcDestination[4];int rcSource[4];byte opacity;int fVisible;int fSourceClientAreaOnly")
- DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "dwFlags", BitOR($DWM_TNP_RECTDESTINATION, $DWM_TNP_OPACITY, $DWM_TNP_VISIBLE, $DWM_TNP_SOURCECLIENTAREAONLY))
- DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_X, 1)
- DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Y, 2)
- DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Width, 3)
- DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "rcDestination", $rcDest_Height, 4)
- DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "opacity", $rcOpacity)
- DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fVisible", $rcReadOnly)
- DllStructSetData($tDWM_THUMBNAIL_PROPERTIES, "fSourceClientAreaOnly", $rcClientAreaOnly)
- $pDWM_THUMBNAIL_PROPERTIES = DllStructGetPtr($tDWM_THUMBNAIL_PROPERTIES)
- $aRet = DllCall("dwmapi.dll", "int", "DwmUpdateThumbnailProperties", "ptr", $hThumbID, "ptr", $pDWM_THUMBNAIL_PROPERTIES)
- If Not IsArray($aRet) Then
- Return SetError(1, 0, 0) ; Update thumbnail failed
- EndIf
- ;_ArrayDisplay($aRet, "DwmAPI.au3 - L80 - aRet array")
- EndFunc ;==>_DWM_Thumbnail_Update_Properties
- Func _DWM_Thumbnail_Unregister($hThumbID)
- $aRet = DllCall("dwmapi.dll", "int", "DwmUnregisterThumbnail", "hwnd", $hThumbID)
- If Not IsArray($aRet) Then
- Return SetError(1, 0, 0) ; Unregister thumbnail failed
- EndIf
- Return $aRet[0]
- EndFunc ;==>_DWM_Thumbnail_Unregister
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement