' ########################################################################################
' Microsoft Windows
' File: dwmapi.inc
' Contents: DWM API declarations
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_dwmapi_PBI)
#DEFINE PBX_dwmapi_PBI
%EQUATE `DWMAPI_INC = 1
#IF NOT %DEF(%MILCORE_KERNEL_COMPONENT)
#INCLUDE ONCE "Legacy/System/WTypes.inc"
#INCLUDE ONCE "Legacy/System/Uxtheme.inc"
#ENDIF
'#include <pshpack1.h>
'// Blur behind data structures
%EQUATE `DWM_BB_ENABLE = &H00000001 ' // fEnable has been specified
%EQUATE `DWM_BB_BLURREGION = &H00000002 ' // hRgnBlur has been specified
%EQUATE `DWM_BB_TRANSITIONONMAXIMIZED = &H00000004 ' // fTransitionOnMaximized has been specified
' // Size = 16 bytes
TYPE DWM_BLURBEHIND BYTE
 dwFlags AS DWORD
 fEnable AS LONG
 hRgnBlur AS DWORD ' HRGN
 fTransitionOnMaximized AS LONG
END TYPE
'// Window attributes
' enum DWMWINDOWATTRIBUTE
%EQUATE `DWMWA_NCRENDERING_ENABLED = 1 ' // [get] Is non-client rendering enabled/disabled
%EQUATE `DWMWA_NCRENDERING_POLICY = 2 ' // [set] Non-client rendering policy
%EQUATE `DWMWA_TRANSITIONS_FORCEDISABLED = 3 ' // [set] Potentially enable/forcibly disable transitions
%EQUATE `DWMWA_ALLOW_NCPAINT = 4 ' // [set] Allow contents rendered in the non-client area to be visible on the DWM-drawn frame.
%EQUATE `DWMWA_CAPTION_BUTTON_BOUNDS = 5 ' // [get] Bounds of the caption button area in window-relative space.
%EQUATE `DWMWA_NONCLIENT_RTL_LAYOUT = 6 ' // [set] Is non-client content RTL mirrored
%EQUATE `DWMWA_FORCE_ICONIC_REPRESENTATION = 7 ' // [set] Force this window to display iconic thumbnails.
%EQUATE `DWMWA_FLIP3D_POLICY = 8 ' // [set] Designates how Flip3D will treat the window.
%EQUATE `DWMWA_EXTENDED_FRAME_BOUNDS = 9 ' // [get] Gets the extended frame bounds rectangle in screen space
%EQUATE `DWMWA_HAS_ICONIC_BITMAP = 10 ' // [set] Indicates an available bitmap when there is no better thumbnail representation.
%EQUATE `DWMWA_DISALLOW_PEEK = 11 ' // [set] Don't invoke Peek on the window.
%EQUATE `DWMWA_EXCLUDED_FROM_PEEK = 12 ' // [set] LivePreview exclusion information
%EQUATE `DWMWA_LAST = 13
' // Non-client rendering policy attribute values
' enum DWMNCRENDERINGPOLICY
%EQUATE `DWMNCRP_USEWINDOWSTYLE = 0 ' // Enable/disable non-client rendering based on window style
%EQUATE `DWMNCRP_DISABLED = 1 ' // Disabled non-client rendering; window style is ignored
%EQUATE `DWMNCRP_ENABLED = 2 ' // Enabled non-client rendering; window style is ignored
%EQUATE `DWMNCRP_LAST = 3
' // Values designating how Flip3D treats a given window.
' enum DWMFLIP3DWINDOWPOLICY
%EQUATE `DWMFLIP3D_DEFAULT = 0 ' // Hide or include the window in Flip3D based on window style and visibility.
%EQUATE `DWMFLIP3D_EXCLUDEBELOW = 1 ' // Display the window under Flip3D and disabled.
%EQUATE `DWMFLIP3D_EXCLUDEABOVE = 2 ' // Display the window above Flip3D and enabled.
%EQUATE `DWMFLIP3D_LAST = 3
' // Thumbnails
'typedef HANDLE HTHUMBNAIL;
'typedef HTHUMBNAIL* PHTHUMBNAIL;
%EQUATE `DWM_TNP_RECTDESTINATION = &H00000001
%EQUATE `DWM_TNP_RECTSOURCE = &H00000002
%EQUATE `DWM_TNP_OPACITY = &H00000004
%EQUATE `DWM_TNP_VISIBLE = &H00000008
%EQUATE `DWM_TNP_SOURCECLIENTAREAONLY = &H00000010
' // Size = 45 bytes
TYPE DWM_THUMBNAIL_PROPERTIES BYTE
 dwFlags AS DWORD
 rcDestination AS RECT
 rcSource AS RECT
 opacity AS BYTE ' BYTE
 fVisible AS LONG
 fSourceClientAreaOnly AS LONG
END TYPE
' // Video enabling apis
'typedef ULONGLONG DWM_FRAME_COUNT;
'typedef ULONGLONG QPC_TIME;
' // Size = 8 bytes
TYPE UNSIGNED_RATIO BYTE
 uiNumerator AS DWORD ' UINT32
 uiDenominator AS DWORD ' UINT32
END TYPE
'typedef struct _DWM_TIMING_INFO
'{
' UINT32 cbSize;
' // Data on DWM composition overall
' // Monitor refresh rate
' UNSIGNED_RATIO rateRefresh;
' // Actual period
' QPC_TIME qpcRefreshPeriod;
' // composition rate
' UNSIGNED_RATIO rateCompose;
' // QPC time at a VSync interupt
' QPC_TIME qpcVBlank;
' // DWM refresh count of the last vsync
' // DWM refresh count is a 64bit number where zero is
' // the first refresh the DWM woke up to process
' DWM_FRAME_COUNT cRefresh;
' // DX refresh count at the last Vsync Interupt
' // DX refresh count is a 32bit number with zero
' // being the first refresh after the card was initialized
' // DX increments a counter when ever a VSync ISR is processed
' // It is possible for DX to miss VSyncs
' //
' // There is not a fixed mapping between DX and DWM refresh counts
' // because the DX will rollover and may miss VSync interupts
' UINT cDXRefresh;
' // QPC time at a compose time.
' QPC_TIME qpcCompose;
' // Frame number that was composed at qpcCompose
' DWM_FRAME_COUNT cFrame;
' // The present number DX uses to identify renderer frames
' UINT cDXPresent;
' // Refresh count of the frame that was composed at qpcCompose
' DWM_FRAME_COUNT cRefreshFrame;
' // DWM frame number that was last submitted
' DWM_FRAME_COUNT cFrameSubmitted;
' // DX Present number that was last submitted
' UINT cDXPresentSubmitted;
' // DWM frame number that was last confirmed presented
' DWM_FRAME_COUNT cFrameConfirmed;
' // DX Present number that was last confirmed presented
' UINT cDXPresentConfirmed;
' // The target refresh count of the last
' // frame confirmed completed by the GPU
' DWM_FRAME_COUNT cRefreshConfirmed;
' // DX refresh count when the frame was confirmed presented
' UINT cDXRefreshConfirmed;
' // Number of frames the DWM presented late
' // AKA Glitches
' DWM_FRAME_COUNT cFramesLate;
' // the number of composition frames that
' // have been issued but not confirmed completed
' UINT cFramesOutstanding;
' // Following fields are only relavent when an HWND is specified
' // Display frame
' // Last frame displayed
' DWM_FRAME_COUNT cFrameDisplayed;
' // QPC time of the composition pass when the frame was displayed
' QPC_TIME qpcFrameDisplayed;
' // Count of the VSync when the frame should have become visible
' DWM_FRAME_COUNT cRefreshFrameDisplayed;
' // Complete frames: DX has notified the DWM that the frame is done rendering
' // ID of the the last frame marked complete (starts at 0)
' DWM_FRAME_COUNT cFrameComplete;
' // QPC time when the last frame was marked complete
' QPC_TIME qpcFrameComplete;
' // Pending frames:
' // The application has been submitted to DX but not completed by the GPU
' // ID of the the last frame marked pending (starts at 0)
' DWM_FRAME_COUNT cFramePending;
' // QPC time when the last frame was marked pending
' QPC_TIME qpcFramePending;
' // number of unique frames displayed
' DWM_FRAME_COUNT cFramesDisplayed;
' // number of new completed frames that have been received
' DWM_FRAME_COUNT cFramesComplete;
' // number of new frames submitted to DX but not yet complete
' DWM_FRAME_COUNT cFramesPending;
' // number of frames available but not displayed, used or dropped
' DWM_FRAME_COUNT cFramesAvailable;
' // number of rendered frames that were never
' // displayed because composition occured too late
' DWM_FRAME_COUNT cFramesDropped;
' // number of times an old frame was composed
' // when a new frame should have been used
' // but was not available
' DWM_FRAME_COUNT cFramesMissed;
' // the refresh at which the next frame is
' // scheduled to be displayed
' DWM_FRAME_COUNT cRefreshNextDisplayed;
' // the refresh at which the next DX present is
' // scheduled to be displayed
' DWM_FRAME_COUNT cRefreshNextPresented;
' // The total number of refreshes worth of content
' // for this HWND that have been displayed by the DWM
' // since DwmSetPresentParameters was called
' DWM_FRAME_COUNT cRefreshesDisplayed;
' // The total number of refreshes worth of content
' // that have been presented by the application
' // since DwmSetPresentParameters was called
' DWM_FRAME_COUNT cRefreshesPresented;
' // The actual refresh # when content for this
' // window started to be displayed
' // it may be different than that requested
' // DwmSetPresentParameters
' DWM_FRAME_COUNT cRefreshStarted;
' // Total number of pixels DX redirected
' // to the DWM.
' // If Queueing is used the full buffer
' // is transfered on each present.
' // If not queuing it is possible only
' // a dirty region is updated
' ULONGLONG cPixelsReceived;
' // Total number of pixels drawn.
' // Does not take into account if
' // if the window is only partial drawn
' // do to clipping or dirty rect management
' ULONGLONG cPixelsDrawn;
' // The number of buffers in the flipchain
' // that are empty. An application can
' // present that number of times and guarantee
' // it won't be blocked waiting for a buffer to
' // become empty to present to
' DWM_FRAME_COUNT cBuffersEmpty;
'} DWM_TIMING_INFO;
' // Size = 292 bytes
TYPE DWM_TIMING_INFO BYTE
 cbSize AS DWORD ' UINT32
 rateRefresh AS UNSIGNED_RATIO
 qpcRefreshPeriod AS QUAD ' QPC_TIME
 rateCompose AS UNSIGNED_RATIO
 qpcVBlank AS QUAD ' QPC_TIME
 cRefresh AS QUAD ' DWM_FRAME_COUNT
 cDXRefresh AS DWORD ' UINT
 qpcCompose AS QUAD ' QPC_TIME
 cFrame AS QUAD ' DWM_FRAME_COUNT
 cDXPresent AS DWORD ' UINT
 cRefreshFrame AS QUAD ' DWM_FRAME_COUNT
 cFrameSubmitted AS QUAD ' DWM_FRAME_COUNT
 cDXPresentSubmitted AS DWORD ' UINT
 cFrameConfirmed AS QUAD ' DWM_FRAME_COUNT
 cDXPresentConfirmed AS DWORD ' UINT
 cRefreshConfirmed AS QUAD ' DWM_FRAME_COUNT
 cDXRefreshConfirmed AS DWORD ' UINT
 cFramesLate AS QUAD ' DWM_FRAME_COUNT
 cFramesOutstanding AS DWORD ' UINT
 cFrameDisplayed AS QUAD ' DWM_FRAME_COUNT
 qpcFrameDisplayed AS QUAD ' QPC_TIME
 cRefreshFrameDisplayed AS QUAD ' DWM_FRAME_COUNT
 cFrameComplete AS QUAD ' DWM_FRAME_COUNT
 qpcFrameComplete AS QUAD ' QPC_TIME
 cFramePending AS QUAD ' DWM_FRAME_COUNT
 qpcFramePending AS QUAD ' QPC_TIME
 cFramesDisplayed AS QUAD ' DWM_FRAME_COUNT
 cFramesComplete AS QUAD ' DWM_FRAME_COUNT
 cFramesPending AS QUAD ' DWM_FRAME_COUNT
 cFramesAvailable AS QUAD ' DWM_FRAME_COUNT
 cFramesDropped AS QUAD ' DWM_FRAME_COUNT
 cFramesMissed AS QUAD ' DWM_FRAME_COUNT
 cRefreshNextDisplayed AS QUAD ' DWM_FRAME_COUNT
 cRefreshNextPresented AS QUAD ' DWM_FRAME_COUNT
 cRefreshesDisplayed AS QUAD ' DWM_FRAME_COUNT
 cRefreshesPresented AS QUAD ' DWM_FRAME_COUNT
 cRefreshStarted AS QUAD ' DWM_FRAME_COUNT
 cPixelsReceived AS QUAD ' ULONGLONG
 cPixelsDrawn AS QUAD ' ULONGLONG
 cBuffersEmpty AS QUAD ' DWM_FRAME_COUNT
END TYPE
' enum DWM_SOURCE_FRAME_SAMPLING
'// Use the first source frame that
'// includes the first refresh of the output frame
%EQUATE `DWM_SOURCE_FRAME_SAMPLING_POINT = 0
'// use the source frame that includes the most
'// refreshes of out the output frame
'// in case of multiple source frames with the
'// same coverage the last will be used
%EQUATE `DWM_SOURCE_FRAME_SAMPLING_COVERAGE = 1
' // Sentinel value
%EQUATE `DWM_SOURCE_FRAME_SAMPLING_LAST = 2
'static const UINT c_DwmMaxQueuedBuffers = 8;
'static const UINT c_DwmMaxMonitors = 16;
'static const UINT c_DwmMaxAdapters = 16;
%EQUATE `c_DwmMaxQueuedBuffers = 8
%EQUATE `c_DwmMaxMonitors = 16
%EQUATE `c_DwmMaxAdapters = 16
' // Size = 40 bytes
TYPE DWM_PRESENT_PARAMETERS BYTE
 cbSize AS DWORD ' UINT32
 fQueue AS LONG
 cRefreshStart AS QUAD ' DWM_FRAME_COUNT
 cBuffer AS DWORD ' UINT
 fUseSourceRate AS LONG
 rateSource AS UNSIGNED_RATIO
 cRefreshesPerFrame AS DWORD ' UINT
 eSampling AS LONG ' DWM_SOURCE_FRAME_SAMPLING
END TYPE
%EQUATE `DWM_FRAME_DURATION_DEFAULT = -1
DECLARE FUNCTION DwmDefWindowProc LIB "dwmapi.dll" ALIAS "DwmDefWindowProc" ( BYVAL hWnd AS QUAD , BYVAL msg AS QUAD , BYVAL wParam AS QUAD , BYVAL lParam AS LONG , BYREF plResult AS LONG ) AS LONG
DECLARE FUNCTION DwmEnableBlurBehindWindow LIB "dwmapi.dll" ALIAS "DwmEnableBlurBehindWindow" ( BYVAL hWnd AS QUAD
 , BYREF pBlurBehind AS DWM_BLURBEHIND
 ) AS LONG
%EQUATE `DWM_EC_DISABLECOMPOSITION = 0
%EQUATE `DWM_EC_ENABLECOMPOSITION = 1
DECLARE FUNCTION DwmEnableComposition LIB "dwmapi.dll" ALIAS "DwmEnableComposition" ( BYVAL uCompositionAction AS QUAD ) AS LONG
DECLARE FUNCTION DwmEnableMMCSS LIB "dwmapi.dll" ALIAS "DwmEnableMMCSS" ( BYVAL fEnableMMCSS AS LONG
 ) AS LONG
DECLARE FUNCTION DwmExtendFrameIntoClientArea LIB "dwmapi.dll" ALIAS "DwmExtendFrameIntoClientArea" ( BYVAL hWnd AS DWORD
 , BYREF pMarInset AS MARGINS
 ) AS LONG
DECLARE FUNCTION DwmGetColorizationColor LIB "dwmapi.dll" ALIAS "DwmGetColorizationColor" ( BYREF pcrColorization AS DWORD
 , BYREF pfOpaqueBlend AS LONG
 ) AS LONG
DECLARE FUNCTION DwmGetCompositionTimingInfo LIB "dwmapi.dll" ALIAS "DwmGetCompositionTimingInfo" ( BYVAL hwnd AS DWORD
 , BYREF pTimingInfo AS DWM_TIMING_INFO
 ) AS LONG
DECLARE FUNCTION DwmGetWindowAttribute LIB "dwmapi.dll" ALIAS "DwmGetWindowAttribute" ( BYVAL hwnd AS DWORD
 , BYVAL dwAttribute AS DWORD
 , BYREF pvAttribute AS ANY
 , BYVAL cbAttribute AS DWORD
 ) AS LONG
DECLARE FUNCTION DwmIsCompositionEnabled LIB "dwmapi.dll" ALIAS "DwmIsCompositionEnabled" ( BYREF pfEnabled AS LONG
 ) AS LONG
DECLARE FUNCTION DwmModifyPreviousDxFrameDuration LIB "dwmapi.dll" ALIAS "DwmModifyPreviousDxFrameDuration" ( BYVAL hwnd AS DWORD
 , BYVAL cRefreshes AS LONG
 , BYVAL fRelative AS LONG
 ) AS LONG
DECLARE FUNCTION DwmQueryThumbnailSourceSize LIB "dwmapi.dll" ALIAS "DwmQueryThumbnailSourceSize" ( BYVAL hThumbnail AS DWORD
 , BYREF pSize AS SIZE
 ) AS LONG
DECLARE FUNCTION DwmRegisterThumbnail LIB "dwmapi.dll" ALIAS "DwmRegisterThumbnail" ( BYVAL hwndDestination AS DWORD
 , BYVAL hwndSource AS DWORD
 , BYREF phThumbnailId AS DWORD
 ) AS LONG
DECLARE FUNCTION DwmSetDxFrameDuration LIB "dwmapi.dll" ALIAS "DwmSetDxFrameDuration" ( BYVAL hwnd AS DWORD
 , BYVAL cRefreshes AS LONG
 ) AS LONG
DECLARE FUNCTION DwmSetPresentParameters LIB "dwmapi.dll" ALIAS "DwmSetPresentParameters" ( BYVAL hwnd AS DWORD
 , BYREF pPresentParams AS DWM_PRESENT_PARAMETERS
 ) AS LONG
DECLARE FUNCTION DwmSetWindowAttribute LIB "dwmapi.dll" ALIAS "DwmSetWindowAttribute" ( BYVAL hwnd AS DWORD
 , BYVAL dwAttribute AS DWORD
 , BYREF pvAttribute AS ANY
 , BYVAL cbAttribute AS DWORD
 ) AS LONG
DECLARE FUNCTION DwmUnregisterThumbnail LIB "dwmapi.dll" ALIAS "DwmUnregisterThumbnail" ( BYVAL hThumbnailId AS DWORD
 ) AS LONG
DECLARE FUNCTION DwmUpdateThumbnailProperties LIB "dwmapi.dll" ALIAS "DwmUpdateThumbnailProperties" ( BYVAL hThumbnailId AS DWORD
 , BYREF ptnProperties AS DWM_THUMBNAIL_PROPERTIES
 ) AS LONG
'#if(_WIN32_WINNT >= 0x0601)
%EQUATE `DWM_SIT_DISPLAYFRAME = &H00000001 ' // Display a window frame around the provided bitmap
DECLARE FUNCTION DwmSetIconicThumbnail LIB "dwmapi.dll" ALIAS "DwmSetIconicThumbnail" ( BYVAL hwnd AS QUAD , BYVAL hbmp AS QUAD , BYVAL dwSITFlags AS QUAD ) AS LONG
DECLARE FUNCTION DwmSetIconicLivePreviewBitmap LIB "dwmapi.dll" ALIAS "DwmSetIconicLivePreviewBitmap" ( BYVAL hwnd AS QUAD
 , BYVAL hbmp AS DWORD
 , BYREF pptClient AS POINT
 , BYVAL dwSITFlags AS DWORD
 ) AS LONG
DECLARE FUNCTION DwmInvalidateIconicBitmaps LIB "dwmapi.dll" ALIAS "DwmInvalidateIconicBitmaps" ( BYVAL hwnd AS DWORD
 ) AS LONG
'#endif /* _WIN32_WINNT >= 0x0601 */
DECLARE FUNCTION DwmAttachMilContent LIB "dwmapi.dll" ALIAS "DwmAttachMilContent" ( BYVAL hwnd AS QUAD ) AS LONG
DECLARE FUNCTION DwmDetachMilContent LIB "dwmapi.dll" ALIAS "DwmDetachMilContent" ( BYVAL hwnd AS QUAD
 ) AS LONG
DECLARE FUNCTION DwmFlush LIB "dwmapi.dll" ALIAS "DwmFlush" ( ) AS LONG
#IF NOT %DEF(%MILCORE_KERNEL_COMPONENT)
#IF NOT %DEF(%MIL_MATRIX3X2D_DEFINED)
' // Size = 48 bytes
TYPE MIL_MATRIX3X2D BYTE
 S_11 AS DOUBLE ' DOUBLE
 S_12 AS DOUBLE ' DOUBLE
 S_21 AS DOUBLE ' DOUBLE
 S_22 AS DOUBLE ' DOUBLE
 DX AS DOUBLE ' DOUBLE
 DY AS DOUBLE ' DOUBLE
END TYPE
%EQUATE `MIL_MATRIX3X2D_DEFINED = 1
#ENDIF ' // _MIL_MATRIX3X2D_DEFINED
'#ifndef MILCORE_MIL_MATRIX3X2D_COMPAT_TYPEDEF
'// Compatibility for Vista dwm api.
'typedef MilMatrix3x2D MIL_MATRIX3X2D;
'#define MILCORE_MIL_MATRIX3X2D_COMPAT_TYPEDEF
'#endif MILCORE_MIL_MATRIX3X2D_COMPAT_TYPEDEF
DECLARE FUNCTION DwmGetGraphicsStreamTransformHint LIB "dwmapi.dll" ALIAS "DwmGetGraphicsStreamTransformHint" ( BYVAL uIndex AS QUAD , BYREF pTransform AS MIL_MATRIX3X2D ) AS LONG
DECLARE FUNCTION DwmGetGraphicsStreamClient LIB "dwmapi.dll" ALIAS "DwmGetGraphicsStreamClient" ( BYVAL uIndex AS QUAD
 , BYREF pClientUuid AS GUID
 ) AS LONG
#ENDIF ' // MILCORE_KERNEL_COMPONENT
DECLARE FUNCTION DwmGetTransportAttributes LIB "dwmapi.dll" ALIAS "DwmGetTransportAttributes" ( BYREF pfIsRemoting AS LONG , BYREF pfIsConnected AS LONG , BYREF pDwGeneration AS QUAD ) AS LONG
'#include <poppack.h>
#ENDIF
