Jump to content

Win10 DWM Blur with Rounded Corners Help?


Biatu
 Share

Recommended Posts

I am attempting to create a translucent GUI with the blur effect, and I got everything but the rounding to work correctly.

Anyone know how to get rid of the black corners?

Thank you!


This is what I have so far:
 

#include <GUIConstants.au3>
#include <WinAPI.au3>
#include <WinAPIGdi.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

If _WinAPI_DwmIsCompositionEnabled() Then $iHasDWM=1
Local $iHeight=300
Local $iWidth=300
$hGUI = GUICreate("Windows 10 Blur", $iWidth, $iHeight,-1,-1,$WS_POPUP)
GUISetBkColor(0x000000)
GUISetState()

If $iHasDWM Then
    Local $hRgn = _WinAPI_CreateRoundRectRgn(0,0,$iWidth+1,$iHeight+1,50,50)
    Local $hFormRgn=_WinAPI_CreateRectRgnIndirect(_WinAPI_GetClientRect($hGUI))
    Local $hRgnTest=_WinAPI_CreateNullRgn()
    _WinAPI_CombineRgn($hRgnTest,$hRgn,$hFormRgn,$RGN_XOR)
    _WinAPI_DwmEnableBlurBehindWindow($hGUI,1,1,$hRgnTest)
    _WinAPI_DwmEnableBlurBehindWindow10($hGUI)
EndIf
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd


; #FUNCTION# ====================================================================================================================
; Name ..........: _WinAPI_DwmEnableBlurBehindWindow10
; Description ...: Enables Aero-like blurred background in Windows 10.
; Syntax ........: _WinAPI_DwmEnableBlurBehindWindow10($hWnd[, $iMode = $ACCENT_ENABLE_BLURBEHIND])
; Parameters ....: $hWnd                - Window handle.
;                  $bEnable             - [optional] Enable or disable the blur effect.
; Return values .: 1 on success, 0 otherwise. Call _WinAPI_GetLastError on failure for more information.
; Author ........: scintilla4evr
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........: http://vhanla.codigobit.info/2015/07/enable-windows-10-aero-glass-aka-blur.html and http://undoc.airesoft.co.uk/user32.dll/SetWindowCompositionAttribute.php
; Example .......: Yes
; ===============================================================================================================================
Func _WinAPI_DwmEnableBlurBehindWindow10($hWnd, $bEnable = True)
    Local $tAccentPolicy = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId")
    Local $tAttrData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size")
    $tAccentPolicy.AccentState = $bEnable ? 3 : 0
    $tAttrData.Attribute = 19 ; WCA_ACCENT_POLICY
    $tAttrData.DataBuffer = DllStructGetPtr($tAccentPolicy)
    $tAttrData.Size = DllStructGetSize($tAccentPolicy)

    Local $aResult = DllCall("user32.dll", "bool", "SetWindowCompositionAttribute", "hwnd", $hWnd, "ptr", DllStructGetPtr($tAttrData))
    If @error Then Return SetError(@error, @extended, 0)

    Return $aResult[0]
EndFunc

 

Edited by Biatu

What is what? What is what.

Link to comment
Share on other sites

@Biatu, Have you tried setting the window to the same rounded region, you probably have the window as a rectangular region and therefore the repaint isn't happening 'around' the window

    _WinAPI_SetWindowRgn ( $hGUI, $hRgn, True )

[most likely put prior to _WinAPI_CombineRgn($hRgnTest,$hRgn,$hFormRgn,$RGN_XOR)] {edit}

if that doesn't work try forcing a repaint or changing the backcolor and see if it changes

    _WinAPI_RedrawWindow ($hGUI) ;

 

Sorry, I don't have Win10 to test on

Edited by Bilgus
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...