#include <GDIPlus.au3>
#include <GUIConstants.au3>
_GDIPlus_Startup ()
Global Const $DWM_BB_ENABLE = 0x00000001
Global $MyArea[4] = [0, 0, 0, 45]
$Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
$sStruct = DllStructCreate("dword;int;ptr;int")
$hGUI = GUICreate("Windows Vista DWM", 243, 243)
;$Label = GUICtrlCreateLabel("Aero Test", 10, 10)
$Apply = GUICtrlCreateButton("Apply", 80, 104, 83, 25, 0)
$ICE = GUICtrlCreateButton("DWM Check", 80, 134, 83, 25, 0)
GUISetState()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
_GDIPlus_GraphicsDrawString ($hGraphic, "This is a test string on DWM.", 35, 20)
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_Shutdown ()
Exit
Case $Apply
;_DWM_Aero_ApplyGlass($hGUI)
_DWM_Aero_EnableBlurBehind($hGUI)
;_DWM_Aero_ApplyGlassArea($hGUI, $MyArea, 0xE2E2E2)
If Not @error Then
GUICtrlSetColor($Apply, 0xFFFFFF)
GUICtrlSetBkColor($Apply, 0x000000)
GUICtrlSetColor($ICE, 0xFFFFFF)
GUICtrlSetBkColor($ICE, 0x000000)
;GuiCtrlSetColor($Label, 0xFFFFFF)
EndIf
Case $ICE
If _DWM_ICE() Then
MsgBox(0, "_DWM_Aero_ICE", "DWM is enabled!")
Else
MsgBox(0, "_DWM_Aero_ICE", "DWM is NOT enabled!")
EndIf
EndSwitch
WEnd
; #FUNCTION#;===============================================================================
;
; Name...........: _DWM_Aero_ApplyGlass
; Description ...: Applys glass effect to a window
; Syntax.........: _DWM_Aero_ApplyGlass($hWnd, [$bColor)
; Parameters ....: $hWnd - Window handle:
; $bColor - Background color
; Return values .: Success - No return
; Failure - Returns 0
; Author ........: James Brooks
; Modified.......:
; Remarks .......: Thanks to weaponx!
; Related .......:
; Link ..........;
; Example .......; Yes
;
;;==========================================================================================
Func _DWM_Aero_ApplyGlass($hWnd, $bColor = 0x000000)
If Not _IsWinAero() Then
SetError(0, 0, -1)
Return 0
Else
GUISetBkColor($bColor); Must be here!
$Ret = DllCall("dwmapi.dll", "long", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", DllStructGetPtr($Struct))
If @error Then
SetError(0)
Return 0
Else
Return $Ret
EndIf
EndIf
EndFunc ;==>_DWM_Aero_ApplyGlass
; #FUNCTION#;===============================================================================
;
; Name...........: _DWM_Aero_ApplyGlassArea
; Description ...: Applys glass effect to a window area
; Syntax.........: _DWM_Aero_ApplyGlassArea($hWnd, $Area, [$bColor)
; Parameters ....: $hWnd - Window handle:
; $Area - Array containing area points
; $bColor - Background color
; Return values .: Success - No return
; Failure - Returns 0
; Author ........: James Brooks
; Modified.......:
; Remarks .......: Thanks to monoceres!
; Related .......:
; Link ..........;
; Example .......; Yes
;
;;==========================================================================================
Func _DWM_Aero_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000)
If Not _IsWinAero() Then
SetError(0, 0, -1)
Return 0
Else
If _DWM_ICE() Then
ConsoleWrite("ICE ENABLED!" & @CRLF)
If IsArray($Area) Then
DllStructSetData($Struct, "cxLeftWidth", $Area[0])
DllStructSetData($Struct, "cxRightWidth", $Area[1])
DllStructSetData($Struct, "cyTopHeight", $Area[2])
DllStructSetData($Struct, "cyBottomHeight", $Area[3])
GUISetBkColor($bColor); Must be here!
$Ret = DllCall("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($Struct))
If @error Then
SetError(0, 0, 1)
Return 0
Else
Return $Ret
EndIf
Else
ConsoleWrite("ICE DISABLED!" & @CRLF)
SetError(1)
Return 0
EndIf
Else
SetError(2, 0, 2)
Return 0
EndIf
EndIf
EndFunc ;==>_DWM_Aero_ApplyGlassArea
; #FUNCTION#;===============================================================================
;
; Name...........: _DWM_Aero_EnableBlurBehind
; Description ...: Enables the blur effect on the provided window handle.
; Syntax.........: _DWM_Aero_EnableBlurBehind($hWnd)
; Parameters ....: $hWnd - Window handle:
; Return values .: Success - No return
; Failure - Returns 0
; Author ........: James Brooks
; Modified.......:
; Remarks .......: Thanks to komalo
; Related .......:
; Link ..........;
; Example .......; Yes
;
;;==========================================================================================
Func _DWM_Aero_EnableBlurBehind($hWnd, $bColor = 0x000000)
If Not _IsWinAero() Then
SetError(0, 0, -1)
Return 0
Else
DllStructSetData($sStruct, 1, $DWM_BB_ENABLE)
DllStructSetData($sStruct, 2, "1")
DllStructSetData($sStruct, 4, "1")
GUISetBkColor($bColor); Must be here!
$Ret = DllCall("dwmapi.dll", "int", "DwmEnableBlurBehindWindow", "hwnd", $hWnd, "ptr", DllStructGetPtr($sStruct))
If @error Then
SetError(0, 0, 1)
Return 0
Else
Return $Ret
EndIf
EndIf
EndFunc ;==>_DWM_Aero_EnableBlurBehind
; #FUNCTION#;===============================================================================
;
; Name...........: _DWM_ICE
; Description ...: Returns 1 if DWM is enabled or 0 if not
; Syntax.........: _DWM_ICE()
; Parameters ....:
; Return values .: Success - Returns 1
; Failure - Returns 0
; Author ........: James Brooks
; Example .......; Yes
;
;;==========================================================================================
Func _DWM_ICE()
If Not _IsWinAero() Then
$ICEStruct = DllStructCreate("int;")
$Ret = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($ICEStruct))
If @error Then
SetError(0, 0, -1) ; DWM is not active
Return 0
Else
Return DllStructGetData($ICEStruct, 1)
EndIf
Else
SetError(1, 0, 1) ; Not running Windows 6.1 or above
Return 1
EndIf
EndFunc ;==>_DWM_Aero_ICE
; #FUNCTION#;===============================================================================
;
; Name...........: __GetVersionEx
; Description ...: Returns version number of OS
; Syntax.........: _GetVersionEx()
; Parameters ....:
; Return values .: Success - Returns version integer
; Failure - Returns 0
; Author ........: James Brooks
;
;;==========================================================================================
Func _IsWinAero()
Local $__iVer = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion")
If $__iVer >= 6.1 Then
Return 1
Else
Return 0
EndIf
EndFunc