Jump to content

Real Vista Aero Glass - Four functions


James
 Share

Recommended Posts

Ahh, read the entire topic this time around... Should have the first time... :D

http://www.planet-source-code.com/URLSEO...asp/txtCodeId!69756/lngWid!1/anyname.htm

That appears to show some examples using VB. I'm about to look it over, need to go nab VS real quick. Just pointing it out in-case it helps. :D

The above link may be an answer to FireStorm's question. :D

Ah ha! I believe it would. That'd be amazing if it could be implemented.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

I had to go get VB6, I couldn't get that script up to VB.NET for anything... lol. Of course I am a complete newb... It has been fun messing with that DWM stuff... Sort of complicated to get AutoIt looking the way I want, because of that Aero issue with controls... Which is still apparent in that VB app btw... I'm assuming that every control must be specially created through the DWM API?

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

I had to go get VB6, I couldn't get that script up to VB.NET for anything... lol. Of course I am a complete newb... It has been fun messing with that DWM stuff... Sort of complicated to get AutoIt looking the way I want, because of that Aero issue with controls... Which is still apparent in that VB app btw... I'm assuming that every control must be specially created through the DWM API?

Well it wont run in VB.net as it's VB6 code, or do you mean you were trying to convert it?

DWM has taught me some cool stuff! It's not complicated to get it how you want, when you know that everything in DWM must be hand drawn!

And I took a look at the VB6 code and wow, what a mess. If someone else wants to make a start, go for it, but it's too much for me at this time.

Link to comment
Share on other sites

Well it wont run in VB.net as it's VB6 code, or do you mean you were trying to convert it?

DWM has taught me some cool stuff! It's not complicated to get it how you want, when you know that everything in DWM must be hand drawn!

And I took a look at the VB6 code and wow, what a mess. If someone else wants to make a start, go for it, but it's too much for me at this time.

I meant I had to go get the old VB6 IDE because I couldn't get it converted... lol

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

It appears that all controls must be owner drawn if you want them to display correctly. Now I am a complete GDI noob and there is no way that will happen from me (unless I really get bored). Just a little update for those who can't be arsed to read the thread, this code will display the labels and buttons correctly!

#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("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()

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Apply
            ;_Vista_ApplyGlass($GUI)
            ;_Vista_EnableBlurBehind($GUI)
            _Vista_EnableBlurBehind($GUI)
            GUICtrlSetColor($Apply, 0xFFFFFF)
            GUICtrlSetBkColor($Apply, 0x000000)
            GUICtrlSetColor($ICE, 0xFFFFFF)
            GUICtrlSetBkColor($ICE, 0x000000)
            GuiCtrlSetColor($Label, 0xFFFFFF)
        Case $ICE
            If _Vista_ICE() Then
                MsgBox(0, "_Vista_ICE", "DWM is enabled!")
            Else
                MsgBox(0, "_Vista_ICE", "DWM is NOT enabled!")
            EndIf
    EndSwitch
WEnd

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ApplyGlass
; Description ...: Applys glass effect to a window
; Syntax.........: _Vista_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 _Vista_ApplyGlass($hWnd, $bColor = 0x000000)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        GUISetBkColor($bColor); Must be here!
        $Ret = DllCall("dwmapi.dll", "long", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", DllStructGetPtr($Struct))
        If @error Then
            Return 0
            SetError(1)
        Else
            Return $Ret
        EndIf
    EndIf
EndFunc   ;==>_Vista_ApplyGlass

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ApplyGlassArea
; Description ...: Applys glass effect to a window area
; Syntax.........: _Vista_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 _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        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
                Return 0
            Else
                Return $Ret
            EndIf
        Else
            MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
        EndIf
    EndIf
EndFunc   ;==>_Vista_ApplyGlassArea

; #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)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        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
    EndIf
EndFunc   ;==>_Vista_EnableBlurBehind

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ICE
; Description ...: Returns 1 if DWM is enabled or 0 if not
; Syntax.........: _Vista_ICE()
; Parameters ....:
; Return values .: Success - Returns 1
;                  Failure - Returns 0
; Author ........: James Brooks
; Modified.......:
; Remarks .......: Thanks to BrettF
; Related .......:
; Link ..........;
; Example .......; Yes
;
;;==========================================================================================
Func _Vista_ICE()
    $ICEStruct = DllStructCreate("int;")
    $Ret = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($ICEStruct))
    If @error Then
        Return 0
    Else
        Return DllStructGetData($ICEStruct, 1)
    EndIf
EndFunc   ;==>_Vista_ICE
Link to comment
Share on other sites

It appears that all controls must be owner drawn if you want them to display correctly. Now I am a complete GDI noob and there is no way that will happen from me (unless I really get bored). Just a little update for those who can't be arsed to read the thread, this code will display the labels and buttons correctly!

#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("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()

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Apply
            ;_Vista_ApplyGlass($GUI)
            ;_Vista_EnableBlurBehind($GUI)
            _Vista_EnableBlurBehind($GUI)
            GUICtrlSetColor($Apply, 0xFFFFFF)
            GUICtrlSetBkColor($Apply, 0x000000)
            GUICtrlSetColor($ICE, 0xFFFFFF)
            GUICtrlSetBkColor($ICE, 0x000000)
            GuiCtrlSetColor($Label, 0xFFFFFF)
        Case $ICE
            If _Vista_ICE() Then
                MsgBox(0, "_Vista_ICE", "DWM is enabled!")
            Else
                MsgBox(0, "_Vista_ICE", "DWM is NOT enabled!")
            EndIf
    EndSwitch
WEnd

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ApplyGlass
; Description ...: Applys glass effect to a window
; Syntax.........: _Vista_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 _Vista_ApplyGlass($hWnd, $bColor = 0x000000)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        GUISetBkColor($bColor); Must be here!
        $Ret = DllCall("dwmapi.dll", "long", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "long*", DllStructGetPtr($Struct))
        If @error Then
            Return 0
            SetError(1)
        Else
            Return $Ret
        EndIf
    EndIf
EndFunc   ;==>_Vista_ApplyGlass

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ApplyGlassArea
; Description ...: Applys glass effect to a window area
; Syntax.........: _Vista_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 _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        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
                Return 0
            Else
                Return $Ret
            EndIf
        Else
            MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
        EndIf
    EndIf
EndFunc   ;==>_Vista_ApplyGlassArea

; #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)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        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
    EndIf
EndFunc   ;==>_Vista_EnableBlurBehind

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ICE
; Description ...: Returns 1 if DWM is enabled or 0 if not
; Syntax.........: _Vista_ICE()
; Parameters ....:
; Return values .: Success - Returns 1
;                  Failure - Returns 0
; Author ........: James Brooks
; Modified.......:
; Remarks .......: Thanks to BrettF
; Related .......:
; Link ..........;
; Example .......; Yes
;
;;==========================================================================================
Func _Vista_ICE()
    $ICEStruct = DllStructCreate("int;")
    $Ret = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($ICEStruct))
    If @error Then
        Return 0
    Else
        Return DllStructGetData($ICEStruct, 1)
    EndIf
EndFunc   ;==>_Vista_ICE

Oohh, sexy. The only thing I noticed that is still needed, is possibly the 'glow' effect on the text? Other than that, looks really good!

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Oohh, sexy. The only thing I noticed that is still needed, is possibly the 'glow' effect on the text? Other than that, looks really good!

Thanks Firestorm. I'm going to look into this glow text some more, it's annoying that I haven't solved it yet.

Ok research has led me to the function; DrawThemeTextEx, however I have no idea how to get that to work. Maybe someone wants to make a start from here?file:///C:/Users/James/AppData/Local/Temp/moz-screenshot.png

Edited by JamesBrooks
Link to comment
Share on other sites

Made a pretty sexy installer. It's controlled pretty dynamic, allowing for as many steps as needed, and the GUI controls will always line up perfectly for any size given :D and automatically checks to make sure that all text in the dialog box is showing..

(Doesn't actually install anything (but can easily be made to install something), I want just playing with what I could do with the new sexy functions.)

Posted Image

Doesn't look bad in "Non-Vista" mode actually... lol

Posted Image

#include <GUIConstants.au3>
#include <EditConstants.au3>
#include <GuiEdit.au3>
#include <ButtonConstants.au3>

Global $MyArea[4] = [5, 5, 50, 30], $MyGUI[4] = [550, 150, -1, -1], $Step = 1, $LstStep = 3

$GUI = GUICreate("Windows Installer", $MyGUI[0], $MyGUI[1])
$iTextBox = GUICtrlCreateEdit("", $MyArea[0] - 2, $MyArea[3] + 18, $MyGUI[0] - $MyArea[1] - $MyArea[0] + 4, $MyGUI[1] - $MyArea[2] - $MyArea[3] + 4, BitOR($ES_MULTILINE, $ES_READONLY, $ES_NOHIDESEL))
$Credit = GUICtrlCreateLabel("Trigate Productions", 8, $MyGUI[1] - 20)
$Next = GUICtrlCreateButton("   Next   ", $MyGUI[0] - 60, $MyGUI[1] - 25, -1, -1)
$Back = GUICtrlCreateButton("   Back   ", $MyGUI[0] - 110, $MyGUI[1] - 25)
$Progress = GUICtrlCreateProgress(8, 3, $MyGUI[0] - 15)
$Status = GUICtrlCreateLabel("Status: Waiting", 8, 30, $MyGUI[0] - 25)
GUISetState()
If @OSVersion == "WIN_VISTA" Then; Windows 7 will also return WIN_VISTA
    _Apply()
EndIf

_Step($Progress, $Step, $LstStep, $Status); Set to the first step
_StepText($Step, $iTextBox, $Next, $Back); Set text for first step

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Next
            If GUICtrlRead($Next) = "Finish" Then
                Exit
            Else
                $Step += 1
                If $Step > $LstStep Then
                    $Step = $LstStep
                EndIf
                _Step($Progress, $Step, $LstStep, $Status, 0)
                _StepText($Step, $iTextBox, $Next, $Back)
            EndIf
        Case $Back
            If GUICtrlRead($Back) = "Decline" Then
                _Step($Progress, 0, $LstStep, $Status, "Terms Not Accepted", 0xFF0000)
                _StepText(0, $iTextBox, $Next, $Back)
                While 1
                    $iMsg = GUIGetMsg()
                    If $iMsg = $GUI_EVENT_CLOSE Or $iMsg = $Next Then
                        Exit
                    ElseIf $iMsg = $Back Then
                        $Step = 2
                        _Step($Progress, $Step, $LstStep, $Status)
                        _StepText($Step, $iTextBox, $Next, $Back)
                        ExitLoop
                    EndIf
                WEnd
            Else
                $Step -= 1
                If $Step < 1 Then
                    $Step = 1
                EndIf
                _Step($Progress, $Step, $LstStep, $Status)
                _StepText($Step, $iTextBox, $Next, $Back)
            EndIf
    EndSwitch
WEnd

Func _Apply()
    _Vista_ApplyGlassArea($GUI, $MyArea)
    GUICtrlSetColor($Next, 0xFFFFFF)
    GUICtrlSetBkColor($Next, 0x005500)
    GUICtrlSetColor($Back, 0xFFFFFF)
    GUICtrlSetBkColor($Back, 0x000000)
    GUICtrlSetBkColor($iTextBox, 0x000000)
    GUICtrlSetColor($iTextBox, 0xFFFFFF)
    GUICtrlSetColor($Credit, 0xFFFFFF)
    GUICtrlSetColor($Status, 0xFFFFFF)
EndFunc   ;==>_Apply

Func _StepText($CurStep, $hWnd, $CurBut1, $CurBut2)
    If $CurStep = 1 Then
        GUICtrlSetData($iTextBox, "Welcome to the Trigate Vista installer." & @CRLF & "Please continue to the next step for further instructions.")
        GUICtrlSetData($CurBut1, "Next")
        GUICtrlSetData($CurBut2, "Back")
    ElseIf $CurStep = 2 Then
        GUICtrlSetData($iTextBox, "Welcome to step 2! :D" & @CRLF & "Please accept to continue.")
        GUICtrlSetData($CurBut1, "Accept")
        GUICtrlSetData($CurBut2, "Decline")
    ElseIf $CurStep = 3 Then
        GUICtrlSetData($iTextBox, "Thanks for Accepting!")
        GUICtrlSetData($CurBut1, "Finish")
        GUICtrlSetData($CurBut2, "Back")
    ElseIf $CurStep = 0 Then; Quiting
        GUICtrlSetData($iTextBox, "Sorry, you did not accept the terms of use. Please exit the program or go back.")
        GUICtrlSetData($CurBut1, "Exit")
        GUICtrlSetData($CurBut2, "Back")
    Else
        GUICtrlSetData($iTextBox, "Undefined step :(")
        GUICtrlSetData($CurBut1, "Next")
        GUICtrlSetData($CurBut2, "Back")
    EndIf
    _HeightCheck($MyGUI[1])
EndFunc   ;==>_StepText

Func _Step($hWnd, $CurStep, $LstStep, $hWnd2 = 0, $Info = False, $sColor = 0xFFFFFF); Handle for progress bar, Current Step, Last Step, Handle for Status Label, Info for label
    If Not @OSVersion == "WIN_VISTA" Then
        If $sColor = 0xFFFFFF Then $sColor = 0x000000
    EndIf
    GUICtrlSetData($hWnd, $CurStep / $LstStep * 100)
    If Not $hWnd2 = 0 Then
        If $Info = False Then
            $Info = "Step " & $CurStep & " of " & $LstStep
        EndIf
        GUICtrlSetData($hWnd2, "Status: " & $Info)
        GUICtrlSetColor($hWnd2, $sColor)
    EndIf
EndFunc   ;==>_Step

Func _HeightCheck($HCoord)
    $LCount = _GUICtrlEdit_GetLineCount($iTextBox)
    $LHeight = 10 * $LCount - 10
    If $HCoord < 100 + $LHeight Then
        MsgBox(0, "Warning", "Window is too small (height) to see all the text.. Minimum of " & $LHeight + 100 & " - Currently: " & $HCoord)
    EndIf
EndFunc   ;==>_HeightCheck

; #FUNCTION#;===============================================================================
;
; Name...........: _Vista_ApplyGlassArea
; Description ...: Applys glass effect to a window area
; Syntax.........: _Vista_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 _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000)
    $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
    $sStruct = DllStructCreate("dword;int;ptr;int")
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        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
                Return 0
            Else
                Return $Ret
            EndIf
        Else
            MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
        EndIf
    EndIf
EndFunc   ;==>_Vista_ApplyGlassArea

I'm lovin this glass. Thanks alot :D

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

I was having a few drawing issues James. Not sure why the issues occurs... But this Function seams to fix all my buttons when the drawing issues occurs...

Basically causing a redraw...

Func ButtonFix()
    GUICtrlSetState($Options, $GUI_HIDE)
    GUICtrlSetState($Options, $GUI_SHOW)
    GUICtrlSetState($SendShotFS, $GUI_HIDE)
    GUICtrlSetState($SendShotFS, $GUI_SHOW)
    GUICtrlSetState($PCInfo, $GUI_HIDE)
    GUICtrlSetState($PCInfo, $GUI_SHOW)
EndFunc

The below is how the GUI is setup...

Func Chat()
    Local $Area[4] = [0, 0, 0, 50]
    Opt("GUIResizeMode", 1)
    $oIE = _IECreateEmbedded()
    $ChatForm = GUICreate("x", 800, 650, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

    $PCInfo = GUICtrlCreateButton("Send PC Info", 5 + 210, 607, 110, 41, $WS_GROUP)
    GUICtrlSetOnEvent($PCInfo, "SendInfo")

    $SendShotFS = GUICtrlCreateButton("Send Screenshot", 120 + 210, 607, 110, 41, $WS_GROUP)
    GUICtrlSetOnEvent($SendShotFS, "DoScreenshotFS")

    $Options = GUICtrlCreateButton("Options", 235 + 210, 607, 110, 41, $WS_GROUP)
    GUICtrlSetOnEvent($Options, "ChatOptions")

    If _Vista_ICE() Then
        _Vista_ApplyGlassArea($ChatForm, $Area)
        GUICtrlSetColor($PCInfo, 0xFFFFFF)
        GUICtrlSetBkColor($PCInfo, 0x000000)

        GUICtrlSetColor($SendShotFS, 0xFFFFFF)
        GUICtrlSetBkColor($SendShotFS, 0x000000)

        GUICtrlSetColor($Options, 0xFFFFFF)
        GUICtrlSetBkColor($Options, 0x000000)

    EndIf
    $GUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 800, 600)
    GUICtrlSetResizing($GUIActiveX,32)
    _IENavigate($oIE, "http://chat.ecobytes.net/", 1)

    GUISetState(@SW_SHOW, $ChatForm)
     GUICtrlSetResizing($GUIActiveX, $GUI_DOCKBORDERS)
    $oBody = _IEGetObjByName($oIE, "emoticonsContainer", 0)

    GUICtrlSetColor($PCInfo, 0xFFFFFF)
    GUICtrlSetBkColor($PCInfo, 0x000000)

    GUICtrlSetColor($SendShotFS, 0xFFFFFF)
    GUICtrlSetBkColor($SendShotFS, 0x000000)

    GUICtrlSetColor($Options, 0xFFFFFF)
    GUICtrlSetBkColor($Options, 0x000000)

    GUISetState()

EndFunc   ;==>Chat

The drawing issues primarily occur when the Window is being re-sized, I managed to create events to counter-act the drawing issue by causing redraws with the "ButtonFix()" function above... But it fails in one situation that I know of...

If you drag the Window to the top of the screen, in Windows 7 that causes the Window to me maximized, which poses no issues, nor does restoring it via the button (Or double clicking the title bar works just as well), but if I click & drag the title bar back down from the top, the Window auto-restores so the click & drag succeeds... (Not part of my code, a Windows thing...) The Buttons get a whiteout issue that is fixed by causing some sort of redraw, "Button focus, Window re-size, button click)

So far my implementation pretty much involves polling "ButtonFix()" once a second...

If you would rather me move this to the support forum, I will... I just wasn't sure this was my fault... :D

Posted Image

Please ignore the black-bar... I'm not worried about that, as I think I know what that is... :D

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

The drawing issues primarily occur when the Window is being re-sized, I managed to create events to counter-act the drawing issue by causing redraws with the "ButtonFix()" function above... But it fails in one situation that I know of...

If you drag the Window to the top of the screen, in Windows 7 that causes the Window to me maximized, which poses no issues, nor does restoring it via the button (Or double clicking the title bar works just as well), but if I click & drag the title bar back down from the top, the Window auto-restores so the click & drag succeeds... (Not part of my code, a Windows thing...) The Buttons get a whiteout issue that is fixed by causing some sort of redraw, "Button focus, Window re-size, button click)

So far my implementation pretty much involves polling "ButtonFix()" once a second...

If you would rather me move this to the support forum, I will... I just wasn't sure this was my fault... :D

Very strange problem there. I re-created the exact behaviour with this 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("Windows Vista DWM", 243, 243, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)
$Label = GUICtrlCreateLabel("Aero Test", 10, 10)
$Apply = GUICtrlCreateButton("Apply", 80, 104, 83, 25, 0)
$ICE = GUICtrlCreateButton("DWM Check", 80, 134, 83, 25, 0)
GUISetState()

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Apply
            _Vista_EnableBlurBehind($GUI)
            GUICtrlSetColor($Apply, 0xFFFFFF)
            GUICtrlSetBkColor($Apply, 0x000000)
            GUICtrlSetColor($ICE, 0xFFFFFF)
            GUICtrlSetBkColor($ICE, 0x000000)
            GuiCtrlSetColor($Label, 0xFFFFFF)
        Case $ICE
            If _Vista_ICE() Then
                MsgBox(0, "_Vista_ICE", "DWM is enabled!")
            Else
                MsgBox(0, "_Vista_ICE", "DWM is NOT enabled!")
            EndIf
    EndSwitch
WEnd

Func _Vista_EnableBlurBehind($hWnd, $bColor = 0x000000)
    If @OSVersion <> "WIN_VISTA" Then
        MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!")
        Exit
    Else
        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
    EndIf
EndFunc   ;==>_Vista_EnableBlurBehind

Func _Vista_ICE()
    $ICEStruct = DllStructCreate("int;")
    $Ret = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($ICEStruct))
    If @error Then
        Return 0
    Else
        Return DllStructGetData($ICEStruct, 1)
    EndIf
EndFunc   ;==>_Vista_ICE

(Windows 7) First click Apply. If you drag the window to the top of the desktop so it expands everything is fine (excuse the organization). Drag the titlebar away from the top so that it restores down. Missing a button?

It might have something to do with the:

$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN

variables, perhaps they are causing weird effects?

Link to comment
Share on other sites

  • 1 month later...

Slight update for win7.

Func _Vista_EnableBlurBehind($hWnd, $bColor = 0x000000)
    If Not @OSVersion = "WIN_7" Or Not @OSVersion = "WIN_VISTA" Then
    MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista or Win7!")
    Exit
    Else
    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
    EndIf
EndFunc ;==>_Vista_EnableBlurBehind
Edited by Skrip

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Personally, I removed the OS checks entirely, and simply determined based on the success of this DLL call...

$Ret = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($ICEStruct))

I think I read in some of the updates that it was fixed, but a while back @OSVersion returned "Win_2008" for Win7 & Windows Server 2008.

By default I'm pretty sure that Win2008(server) doesn't come with Aero, so the DLL call fails anyway. Bypassing the need for the @OSVersion macro

entirely... IMO. :)

Simply put, if the DLLCall fails the system either does'nt have Aero enabled, or it doesn't exist... :)

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

Personally, I removed the OS checks entirely, and simply determined based on the success of this DLL call...

$Ret = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($ICEStruct))

I think I read in some of the updates that it was fixed, but a while back @OSVersion returned "Win_2008" for Win7 & Windows Server 2008.

By default I'm pretty sure that Win2008(server) doesn't come with Aero, so the DLL call fails anyway. Bypassing the need for the @OSVersion macro

entirely... IMO. :)

Simply put, if the DLLCall fails the system either does'nt have Aero enabled, or it doesn't exist... :)

Good idea!

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

  • 1 month later...

I've also found that it's a REAL time saver to do something like this...

If _Vista_ICE() Then
    _Vista_EnableBlurBehind($Form1)
    GUICtrlSetDefBkColor(0x000000)
    GUICtrlSetDefColor(0xFFFFFF)
EndIf

Rather than edit the Color, BKColor for each control! :S

Those few lines of code, allow my forms to appear perfectly in Windows XP, and well as Win7/Vista... ;)

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

Link to comment
Share on other sites

  • 2 weeks later...

I've also found that it's a REAL time saver to do something like this...

If _Vista_ICE() Then
    _Vista_EnableBlurBehind($Form1)
    GUICtrlSetDefBkColor(0x000000)
    GUICtrlSetDefColor(0xFFFFFF)
EndIf

Rather than edit the Color, BKColor for each control! :S

Those few lines of code, allow my forms to appear perfectly in Windows XP, and well as Win7/Vista... ;)

Ah sweet! I've never used those functions so completely forgot to even look into them.
Link to comment
Share on other sites

It's a hack using black labels to mask the border if background color <> black, but it works.

Edit:

(I fixed the bug in $L1 label creation line. Should work via cut & paste now.)

Func _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000)
    If Not _GlassEnabled() Then Return 0 

    If IsArray($Area) Then
        If $bColor <> 0x000000 Then
            Local $clientH = _WinAPI_GetClientHeight($hWnd)
            Local $clientW = _WinAPI_GetClientWidth($hWnd)
        EndIf
        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!
        If $bColor <> 0x000000 Then
            Local $L1 = GUICtrlCreateLabel("", 0, 0, $clientW, $Area[2])
            GUICtrlSetBkColor(-1, 0x000000)
            Local $L2 = GUICtrlCreateLabel("", 0, 0, $Area[0], $clientH)
            GUICtrlSetBkColor(-1, 0x000000)
            Local $L3 = GUICtrlCreateLabel("", $clientW - $Area[1], 0, $Area[1], $clientH)
            GUICtrlSetBkColor(-1, 0x000000)
            Local $L4 = GUICtrlCreateLabel("", 0, $clientH - $Area[3], $clientW, $Area[3])
            GUICtrlSetBkColor(-1, 0x000000)
        EndIf
        $Ret = DllCall("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", _
            "hwnd", $hWnd, "ptr", DllStructGetPtr($Struct))
        If @error Then
            Return 0
        Else
            Return $Ret
        EndIf
    Else
        MsgBox(16, "_Vista_ApplyGlassArea", "Area specified is not an array!")
    EndIf
EndFunc ;==>_Vista_ApplyGlassArea

and the _GlassEnabled() is

Global Enum $WIN_95, $WIN_98, $WIN_ME, $WIN_NT, $WIN_2000, $WIN_XP, $WIN_2003, _
        $WIN_VISTA, $WIN_2008

Func _OsLevel()
    Local $ver = @OSVersion
    Local $winVersions[9] = ["WIN_95", "WIN_98", "WIN_ME", "WIN_NT4", "WIN_2000", _
            "WIN_XP", "WIN_2003", "WIN_VISTA", "WIN_2008"]

    For $i = $WIN_95 To UBound($winVersions) - 1
        If $winVersions[$i] = $ver Then Return $i
    Next
EndFunc ;==>_OsLevel

Func _GlassEnabled()
    If _OsLevel() < $WIN_VISTA Then Return 0
    $retValue = Dllcall("dwmapi.dll","int","DwmIsCompositionEnabled","int*","")
    If @error Then Return 0
    return $retValue[1]
EndFunc

I do OsLevel() returning an enumerated type to make comparison easier. Windows8 may not return "WIN_VISTA" but it should be >= $WIN_VISTA etc..

I'm a bit confused on how to apply this to my controls. Can you post a sample code of the images you keep posting to see how it applies. My whole GUI comes out glassed.
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

I'm a bit confused on how to apply this to my controls. Can you post a sample code of the images you keep posting to see how it applies. My whole GUI comes out glassed.

You don't apply this to your controls directly, as the DWM functions I used "breaks" them. You need to apply this to the GUI itself. Take a look at the example I posted on the first page. ;)

If you want glass controls, you need to draw them yourself, something I haven't worked out yet.

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...