Function _Vista_EnableBlurBehind

09/29/2010 00:32 freehuntx#1
Also.

Ich habe vor mal eine coole gui für meinen nächsten trainer zu machen.

Dann bin ich darauf gestoßen.

Ich kann es nicht so gut erklären, hier mal der script:

Code:
#include <GUIConstants.au3>

 $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
 $sStruct = DllStructCreate("dword;int;ptr;int")

 Global $MyArea[4] = [50, 50, 50, 50]

 $GUI = GUICreate("Trainer by FreehuntX", 555, 179, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("Test", 8, 8, 17, 17)
 GUISetState()

 _Vista_EnableBlurBehind($GUI)
 While 1
     $iMsg = GUIGetMsg()
     Switch $iMsg
         Case $GUI_EVENT_CLOSE
             Exit
     EndSwitch
 WEnd

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_EnableBlurBehind
; Description ...: Enables the blur effect on the provided window handle.
; Syntax.........: _Vista_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 _Vista_EnableBlurBehind($hWnd, $bColor = 0x000000)
         Const $DWM_BB_ENABLE = 0x00000001

         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
             Return 0
         Else
             Return $Ret
         EndIf
 EndFunc

Leute die vista haben, sollten den effekt sehen.

Nun mein Problem ist aber dass man die beschriftung der checkbox nicht sehen kann.

Auch ein Label ist nicht sichtbar.

Ist es möglich dass man die schrift eindeutig sieht? also pechschwarz?

danke im vorraus
09/29/2010 08:40 maxi39#2
bei der checkbox haste ein gann dummen fehler gemacht ( der zeigt den text nicht an weil ein zu kurzes text feld vorhanden ist),

erhöh doch mal die zahl die in rot makiert ist:


Code:
$Checkbox1 = GUICtrlCreateCheckbox("Test", 8, 8, [COLOR="Red"]17[/COLOR], 17)
und setz ma darunter ne farbe :
Code:
GUICtrlSetColor(-1, 0x800080)
so:

Code:
[COLOR="Olive"]$Checkbox1 = GUICtrlCreateCheckbox("Test", 8, 8, 100, 17)
GUICtrlSetColor(-1, 0x800080)[/COLOR]

Wo ist da ein Label?

wenn dun label brauchst hier:


PHP Code:
$Label1 GUICtrlCreateLabel("test label"4481524617)
GUICtrlSetColor(-10x800080
Das gesammte script:

Code:
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
 $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
 $sStruct = DllStructCreate("dword;int;ptr;int")

 Global $MyArea[4] = [50, 50, 50, 50]

 $GUI = GUICreate("Trainer by FreehuntX", 555, 179, 192, 124)
[COLOR="Lime"]$Checkbox1 = GUICtrlCreateCheckbox("Test", 8, 8, 100, 17)
GUICtrlSetColor(-1, 0x800080)
$Label1 = GUICtrlCreateLabel("test label", 448, 152, 46, 17)
GUICtrlSetColor(-1, 0x800080)[/COLOR]
GUISetState()

 _Vista_EnableBlurBehind($GUI)
 While 1
     $iMsg = GUIGetMsg()
     Switch $iMsg
         Case $GUI_EVENT_CLOSE
             Exit
     EndSwitch
 WEnd

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_EnableBlurBehind
; Description ...: Enables the blur effect on the provided window handle.
; Syntax.........: _Vista_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 _Vista_EnableBlurBehind($hWnd, $bColor = 0x000000)
         Const $DWM_BB_ENABLE = 0x00000001

         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
             Return 0
         Else
             Return $Ret
         EndIf
	 EndFunc
09/29/2010 18:29 freehuntx#3
naja danke aber man sieht nur die checkbox ohne schrift, und das label in rosa farbe :/
09/29/2010 19:09 Shkal#4
_WinAPI_SetLayeredWindowAttributes does the magic:

Code:
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

$Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")

$GUI = GUICreate("Trainer by FreehuntX", 555, 179, 192, 124)
GUISetState(@SW_SHOW, $GUI)
_Vista_EnableBlurBehind($GUI)

$hDummy = GUICreate("", 555, 179, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI) ; Layered Child GUI erstellen
GUISetBkColor(0xABCDEF) ; GUI einfärben
_WinAPI_SetLayeredWindowAttributes($hDummy, 0xABCDEF,255) ; LayeredWindowAttributes

$Checkbox1 = GUICtrlCreateCheckbox("Test", 8, 8, 200, 20)
$Checkbox1 = GUICtrlCreateLabel("Ich teste noch mehr", 20, 50, 200, 20)
GUISetState(@SW_SHOW, $hDummy)


While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_EnableBlurBehind
; Description ...: Enables the blur effect on the provided window handle.
; Syntax.........: _Vista_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 _Vista_EnableBlurBehind($hWnd, $bColor = 0x000000)
    Const $DWM_BB_ENABLE = 0x00000001
    $sStruct = DllStructCreate("dword;int;ptr;int")
    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))
    $sStruct = 0

    If @error Then
        Return 0
    Else
        Return $Ret
    EndIf
EndFunc   ;==>_Vista_EnableBlurBehind
09/29/2010 19:25 freehuntx#5
Thank u very much :D

Edit:

And how can i do if the user have xp or Win7 that he see a normal gui without this effect?
09/29/2010 19:45 Shkal#6
Also bei Windows 7 funktioniert das ohne Probleme, allerdings muss (genau wie bei Vista) Aero aktiviert sein. Du kannst das @OSVersion Macro nutzen, um zwischen Betriebssystemen zu unterscheiden:


LG
09/29/2010 20:05 freehuntx#7
Wo ist denn da der unterschied? bei den sources?

naja ich mach mal anstatt errormeldung einfach ne andere gui
09/29/2010 20:29 maxi39#8
Quote:
Originally Posted by freehuntx View Post
naja danke aber man sieht nur die checkbox ohne schrift, und das label in rosa farbe :/
komisch, ich bin vista 32bit user und bei mir wird alles perfekt angezeigt
09/29/2010 20:34 Shkal#9
Quote:
Originally Posted by freehuntx View Post
Wo ist denn da der unterschied? bei den sources?
Um genau zu sein, habe ich nur diese Abfrage eingefügt:
Code:
If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
...
EndIf
Wenn also Win7 oder Vista benutzt werden, wird das Layered Fenster usw. erzeugt. andernfalls eben nicht, und es spielt sich alles auf dem "normalen" GUI ab.
09/29/2010 21:53 freehuntx#10
Quote:
Originally Posted by Shkal View Post
Um genau zu sein, habe ich nur diese Abfrage eingefügt:
Code:
If @OSVersion = "WIN_VISTA" Or @OSVersion = "WIN_7" Then
...
EndIf
Wenn also Win7 oder Vista benutzt werden, wird das Layered Fenster usw. erzeugt. andernfalls eben nicht, und es spielt sich alles auf dem "normalen" GUI ab.
oops :D garnicht gesehen :D werde es mal testen
09/29/2010 21:54 Lohde#11
Jo könnte ggf. helfen ^^
09/30/2010 13:50 PenGuin :O#12
Bei mir (Win7 64bit) verschwindet der Aero Effekt beim Verschieben des Fensters und wenn ich wieder in das Fenste nach dem Verschieben hineinklicke, ist alles wieder normal.

Ach und diese Funktion könnte auch ganz nützlich sein:

Code:
 Func _Vista_ApplyGlass($hWnd, $bColor = 0x000000)
	 Local  $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
         GUISetBkColor($bColor)
         $Ret = DllCall("dwmapi.dll", "long", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", DllStructGetPtr($Struct))
         If @error Then
             Return 0
             SetError(1)
         Else
             Return $Ret
         EndIf
 EndFunc ;==>_Vista_ApplyGlass