Sign in to follow this  
Followers 0
EvAsion

DwmEnableBlurBehindWindow using DllCall

7 posts in this topic




what follows is a "ptr" to a DWM_BLURBEHIND structure, which you need to DllStructCreate beforehand.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

what follows is a "ptr" to a DWM_BLURBEHIND structure, which you need to DllStructCreate beforehand.

so something on the lines of

$struct = DllStructCreate("ptr")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif
DllCall("dwmapi.dll","int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"prt",DllStructGetPtr($struct))

only the struct relates to:

DWORD dwFlags;

BOOL fEnable;

HRGN hRgnBlur;

BOOL fTransitionOnMaximized;

Edited by EvAsion

Share this post


Link to post
Share on other sites

only the struct relates to:

DWORD dwFlags;

BOOL fEnable;

HRGN hRgnBlur;

BOOL fTransitionOnMaximized;

Which means

$struct = DllStructCreate("dword; int; ptr; int")

And of course you'll have to set the elements of the struct with DllStructSetData, using values according to MSDN specs.


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

ok this is what i've done. i'm thinking that some of the values inside the structure are wrong. Also with ptr, is null "-1","0" or "". And i'm not sure, but is fTransitionOnMaximized automatic or something because its not used in the example of this function.

$Struct = DllStructCreate("dword;int;ptr;int")
DllStructSetData($Struct,1,BitAnd("DWM_BB_ENABLE","DWM_BB_BLURREGION"))
DllStructSetData($Struct,2,"1")
DllStructSetData($Struct,3,"")
;DllStructSetData($Struct,4,"")

MsgBox(0,"DllStruct","Struct Size: " & DllStructGetSize($Struct) & @CRLF & _
        "Struct pointer: " & DllStructGetPtr($Struct) & @CRLF & _
        "Data:" & @CRLF & _
        DllStructGetData($Struct,1) & @CRLF & _
        DllStructGetData($Struct,2) & @CRLF & _
        DllStructGetData($Struct,3) & @CRLF & _
        DllStructGetData($Struct,4))
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif
DllCall("dwmapi.dll","int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"prt",DllStructGetPtr($Struct))

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Const $DWM_BB_ENABLE = 0x00000001
Const $DWM_BB_BLURREGION = 0x00000002
Const $DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004

$Struct = DllStructCreate("dword;int;ptr;int")
DllStructSetData($Struct,1,BitOr($DWM_BB_ENABLE,$DWM_BB_TRANSITIONONMAXIMIZED)) ;<- to combine, use BitOr (simply + also works), not BitAnd. And of course, these are not strings you're combining.
DllStructSetData($Struct,2,1)  ;<- not a string, but int.
DllStructSetData($Struct,4,1)
DllCall("dwmapi.dll","int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"ptr",DllStructGetPtr($Struct)) ; <- was a typo "prt"

Null pointer is 0 (int, not string). But since upon creation all struct elements are already initialized as 0, there's no need for DllStructSetData($Struct,3,0).

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Wow. well.. it partly works. It makes text, selections and images transparent/blurred, but not the empty space of a gui(wheres theres no controls) which was what i was assuming it would do. It also doesn't blur at the same consistency as window borders and windows media player.

Const $DWM_BB_ENABLE = 0x00000001
Const $DWM_BB_BLURREGION = 0x00000002
Const $DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004


$hWnd = WinGetHandle("Test GUI")
$Struct = DllStructCreate("dword;int;ptr;int")
DllStructSetData($Struct,1,$DWM_BB_ENABLE)
DllStructSetData($Struct,2,"1")
DllStructSetData($Struct,4,"1")
$dll = DllOpen("dwmapi.dll")
DllCall($dll,"int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"ptr",DllStructGetPtr($Struct))
If @error Then
    msgbox(0,"",@error)
EndIf
DllClose($dll)
Edited by EvAsion

Share this post


Link to post
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
Sign in to follow this  
Followers 0