EvAsion Posted June 5, 2008 Share Posted June 5, 2008 (edited) Ok i'm trying to convert some functions from msdn and improve my dllcall skills. I'm having some trouble with the DwmEnableBlueBehindWindow function (MSDN) - specifically using the blur region functionality of it. I'm also having trouble with the DwmRegisterThumbnail and DwmUpdateThumbnailProperties functions. I'm just hoping for some pointers of where i'm going wrong with dllcall in calling these functions. also i'm trying to put controls over a blurred window but the only way i've found to do that is to create child windows that are the same size as the controls, and making child windows for each individual control, how can i make the background truly transparent so that the glass sheet is visible?Here is what i've done so far: (obviously this is for vista only)expandcollapse popupConst $DWM_BB_ENABLE = 0x00000001 Const $DWM_BB_BLURREGION = 0x00000002 Const $DWM_BB_TRANSITIONONMAXIMIZED = 0x00000004 Const $DWM_EC_DISABLECOMPOSITION = 0x00000000 Const $DWM_EC_ENABLECOMPOSITION = 0x00000001 Const $DWM_TNP_RECTDESTINATION = 0x00000001 Const $DWM_TNP_RECTSOURCE = 0x00000002 Const $DWM_TNP_OPACITY = 0x00000004 Const $DWM_TNP_VISIBLE = 0x00000008 Const $DWM_TNP_SOURCECLIENTAREAONLY = 0x00000010 #include<guiconstants.au3> #cs opt("WinTitleMatchMode",2) $gui = GUICreate("OMG",500,500,50,50,-1,$WS_EX_LAYERED);BitOR($WS_EX_TRANSPARENT,$WS_EX_LAYERED)) GUISetState() GUICreate("CHILD",300,300,0,0,$WS_POPUP,$WS_EX_MDICHILD,$gui) $edit = GUICtrlCreateEdit("LOL",0,0,20,50) GUISetState() $hWnd = WinGetHandle("OMG") #ce ;Vista_BackBlur($hwnd) Global $DWMdll = Vista_DWMInitiate() Vista_SetComposition(0) msgbox(0,"","Status of vista desktop composition: "&Vista_GetComposition()) Vista_SetComposition(1) msgbox(0,"","Status of vista desktop composition: "&Vista_GetComposition()) $Colorization = Vista_GetColorization() $gui = GUICreate("DWM stuff",500,500) GUISetBkColor($Colorization[0]) GUISetState() GUICreate("CHILD",300,40,30,30,$WS_POPUP,$WS_EX_MDICHILD,$gui) GUISetBkColor($GUI_BKCOLOR_TRANSPARENT) $edit = GUICtrlCreateEdit("The background is the window colorization colour!",0,0,300,20) GUISetState() do $msg = GUIGetMsg() until $msg = $GUI_EVENT_CLOSE Vista_SetBlurBehind($gui, 1) GUICtrlSetData($edit,"This is with blur-behind enabled") do $msg = GUIGetMsg() until $msg = $GUI_EVENT_CLOSE Vista_SetBlurBehind($gui, 0) GUICtrlSetData($edit,"This is with blur-behind disabled") do $msg = GUIGetMsg() until $msg = $GUI_EVENT_CLOSE Vista_SetBlurBehindRegion($gui, 1,0,0,50,25) GUICtrlSetData($edit,"This is with blur-behind region enabled (not functional)") do $msg = GUIGetMsg() until $msg = $GUI_EVENT_CLOSE $newgui = GUICreate("PREVIEW",0,0,100,100,$WS_POPUP) GUISetState() Vista_CreateThumbnail($newgui,$gui) do $msg = GUIGetMsg() until $msg = $GUI_EVENT_CLOSE Func Vista_DWMInitiate() $dll = DllOpen("dwmapi.dll") return $dll EndFunc Func Vista_DWMEndSession() DllClose($DWMdll) EndFunc Func Vista_SetBlurBehind($hwnd,$on = 1) $Struct = DllStructCreate("dword;int;ptr;int") DllStructSetData($Struct,1,$DWM_BB_ENABLE) If $on = 1 Then DllStructSetData($Struct,2,"1") Else DllStructSetData($Struct,2,"0") EndIf DllStructSetData($Struct,3,"0") DllStructSetData($Struct,4,"1") $call = DllCall($DWMdll,"int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"ptr",DllStructGetPtr($Struct)) EndFunc Func Vista_SetBlurBehindRegion($hwnd,$on = 1,$left = 0,$right = 0,$top = 0,$bottom = 0) #cs $RectStruct = DllStructCreate("int;int;int;int") DllStructSetData($RectStruct,1,$left) DllStructSetData($RectStruct,1,$top) DllStructSetData($RectStruct,1,$right) DllStructSetData($RectStruct,1,$bottom) $call = DllCall($DWMdll,"int","DwmExtendFrameIntoClientArea","hwnd",$hwnd,"ptr",DllStructGetPtr($RectStruct)) #ce $Struct = DllStructCreate("dword;int;ptr;int") DllStructSetData($Struct,1,BitOr($DWM_BB_ENABLE,$DWM_BB_BLURREGION)) If $on = 1 Then DllStructSetData($Struct,2,"1") Else DllStructSetData($Struct,2,"0") EndIf DllStructSetData($Struct,3,"int "&$left &";int "&$right& ";int "&$top& ";int "& $bottom) DllStructSetData($Struct,4,"1") $call = DllCall($DWMdll,"int","DwmEnableBlurBehindWindow","hwnd",$hWnd,"ptr",DllStructGetPtr($Struct)) EndFunc Func Vista_SetComposition($on = 0) If $on = 1 Then Dllcall($DWMdll,"int","DwmEnableComposition","uint",$DWM_EC_ENABLECOMPOSITION) Else Dllcall($DWMdll,"int","DwmEnableComposition","uint",$DWM_EC_DISABLECOMPOSITION) EndIf EndFunc Func Vista_GetComposition() $status = Dllcall($DWMdll,"int","DwmIsCompositionEnabled","int*","") return $status[1] EndFunc Func Vista_GetColorization() $Colorization = Dllcall($DWMdll,"int","DwmGetColorizationColor","dword*","0","int*","0") If @error Then SetError(@error) Return 0 EndIf Local $array[2] Local $colour = Hex($Colorization[1]) $array[0] = "0x"&StringTrimLeft($colour,2) $array[1] = "0x"&StringTrimRight($colour,6) Return $array EndFunc Func Vista_CreateThumbnail($destination,$source) $Rect1 = DllStructCreate("int;int;int;int") DllStructSetData($Rect1,1,0) DllStructSetData($Rect1,2,0) DllStructSetData($Rect1,3,500) DllStructSetData($Rect1,4,500) $Rect2 = DllStructCreate("int;int;int;int") DllStructSetData($Rect2,1,0) DllStructSetData($Rect2,2,0) DllStructSetData($Rect2,3,100) DllStructSetData($Rect2,4,100) $Struct = DllStructCreate("dword;ptr;ptr;byte;int;int") $Struct = DllStructCreate("dword;ptr;ptr;byte;int;int") DllStructSetData($Struct,1,BitOr($DWM_TNP_OPACITY,$DWM_TNP_RECTDESTINATION,$DWM_TNP_RECTSOURCE,$DWM_TNP_SOURCECLIENTAREAONLY,$DWM_TNP_VISIBLE)) DllStructSetData($Struct,2,DllStructGetPtr($rect1)) DllStructSetData($Struct,3,DllStructGetPtr($rect2)) DllStructSetData($Struct,4,"255") DllStructSetData($Struct,5,"1") DllStructSetData($Struct,6,"1") $create = Dllcall($DWMdll,"ptr","DwmRegisterThumbnail","hwnd",$destination,"hwnd",$source,"ptr*","") $update = Dllcall($DWMdll,"ptr","DwmUpdateThumbnailProperties","hwnd",$create[1],"prt",DllStructGetPtr($Struct)) EndFuncOMG EDIT: 100th POST!!!!!!!!!!!!!!!!!! Edited June 5, 2008 by EvAsion |-- Periodic Table --||-- Dynamic Class Timetable --||-- Navigation in Counter-Strike --| Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now