E1M1 Posted December 9, 2012 Posted December 9, 2012 Hello. When I am drawing button on aero glass window. Anything that's dark gets lost. does anyone know how to maintain black text on button.... Or how to have that button unaffected. $hgui = GUICreate("test",100,100) GUISetBkColor(0) GUICtrlCreateButton("test button",0,0) GUISetState() Dim $Area[4] = [0, 0, 0, -1]; Glass area extension _Vista_ApplyGlassArea($hgui,$Area) while GUIGetMsg() <> -3 WEnd Func _Vista_ApplyGlassArea($hWnd, $Area, $bColor = 0x000000) If @OSVersion <> "WIN_VISTA" And @OSVersion <> "WIN_7" Then MsgBox(16, "_Vista_ApplyGlass", "You are not running Vista!") Exit Else If IsArray($Area) Then $Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;") DllStructSetData($Struct, "cxLeftWidth", $Area[0]) DllStructSetData($Struct, "cxRightWidth", $Area[1]) DllStructSetData($Struct, "cyTopHeight", $Area[2]) DllStructSetData($Struct, "cyBottomHeight", $Area[3]) $Ret = DllCall("dwmapi.dll", "long*", "DwmExtendFrameIntoClientArea", "uint", $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 FireFox 1 edited
UEZ Posted December 9, 2012 Posted December 9, 2012 (edited) Try this (modified script from ):expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) If Not IsDeclared("WM_DWMCOMPOSITIonchangeD") Then Global Const $WM_DWMCOMPOSITIonchangeD = 0x031E If Not IsDeclared("tagBP_PAINTPARAMS") Then Global Const $tagBP_PAINTPARAMS = "uint Size;uint Flags;" & $tagRECT & ";ptr BlendFunction;" If Not IsDeclared("tagPAINTSTRUCT") Then Global Const $tagPAINTSTRUCT = "hwnd hDC;int Erase;" & $tagRECT & ";int Restore;int IncUpdate;ubyte Reserved[32]" Global Enum $BPBF_COMPATIBLEBITMAP, $BPBF_DIB, $BPBF_TOPDOWNDIB, $BPBF_TOPDOWNMONODIB Global Const $PRF_CLIENT = 0x00000004 Global $hUxTheme = DllOpen("uxtheme.dll") Global $hGUI = GUICreate("Test", 200, 100) Global $iBtn = GUICtrlCreateButton("Test", 20, 20, 100, 40) Global $hBtn = GUICtrlGetHandle(-1) Global $hCtrlProc = DllCallbackRegister("_CtrlProc", "int", "hwnd;uint;wparam;lparam") Global $hWndProc = _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, DllCallbackGetPtr($hCtrlProc)) GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND") GUIRegisterMsg($WM_DWMCOMPOSITIonchangeD, "_WM_DWMCOMPOSITIonchangeD") _SendMessage($hGUI, $WM_DWMCOMPOSITIonchangeD) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, $hWndProc) DllCallbackFree($hCtrlProc) GUIDelete() DllClose($hUxTheme) Exit Func _CtrlProc($hWnd, $iMsg, $iwParam, $ilParam) Local $hDC, $hBufferedDC, $hPaintBuffer Local $tPS, $pPS Local $tRect Switch $iMsg Case $WM_PAINT $tPS = DllStructCreate($tagPAINTSTRUCT) $pPS = DllStructGetPtr($tPS) $hDC = _WinAPI_BeginPaint($hWnd, $pPS) $tRect = DllStructCreate($tagRECT) For $i = 1 To 4 DllStructSetData($tRect, $i, DllStructGetData($tPS, $i+2)) Next $hPaintBuffer = _WinAPI_BeginBufferedPaint($hDC, DllStructGetPtr($tRect), $BPBF_TOPDOWNDIB, 0, $hBufferedDC, $hUxTheme) _SendMessage($hWnd, $WM_PRINTCLIENT, $hBufferedDC, $PRF_CLIENT) _WinAPI_BufferedPaintSetAlpha($hPaintBuffer, 0, 255, $hUxTheme) If $hPaintBuffer Then _WinAPI_EndBufferedPaint($hPaintBuffer, True, $hUxTheme) _WinAPI_EndPaint($hWnd, $pPS) Return 0 EndSwitch Return _WinAPI_CallWindowProc($hWndProc, $hWnd, $iMsg, $iwParam, $ilParam) EndFunc Func _WM_ERASEBKGND($hWnd, $iMsg, $iwParam, $ilParam) Local $hDC = $iwParam Local $tClientRect = _WinAPI_GetClientRect($hWnd) Local $hBrush = _WinAPI_GetStockObject($BLACK_BRUSH) _WinAPI_FillRect($hDC, DllStructGetPtr($tClientRect), $hBrush) _WinAPI_DeleteObject($hBrush) Return 1 EndFunc Func _WM_DWMCOMPOSITIonchangeD($hWnd, $iMsg, $iwParam, $ilParam) Local $tMargs = DllStructCreate($tagMARGINS) If _WinAPI_DwmIsCompositionEnabled() Then For $i = 1 To 4 DllStructSetData($tMargs, $i, -1) Next _WinAPI_DwmExtendFrameIntoClientArea($hWnd, $tMargs) EndIf Return 0 EndFunc Func _WinAPI_DwmExtendFrameIntoClientArea($hWnd, ByRef $tMargins) Local $aResult = DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($tMargins)) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc Func _WinAPI_DwmIsCompositionEnabled() Local $aResult = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "int*", 0) If @error Then Return SetError(@error, @extended, -1) Return SetError($aResult[0], 0, $aResult[1]) EndFunc Func _WinAPI_BeginPaint($hWnd, $pPaintStruct) Local $aResult = DllCall("user32.dll", "hwnd", "BeginPaint", "hwnd", $hWnd, "ptr", $pPaintStruct) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, 0, $aResult[0]) EndFunc Func _WinAPI_EndPaint($hWnd, $pPaintStruct) Local $aResult = DllCall("user32.dll", "int", "EndPaint", "hwnd", $hWnd, "ptr", $pPaintStruct) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, 0, $aResult[0]) EndFunc Func _WinAPI_BeginBufferedPaint($hDC, $pRc, $iBufferFormat, $pPaintParams ,ByRef $phDC, $hDll = "uxtheme.dll") Local $tHDC = DllStructCreate("hwnd") Local $aResult = DllCall($hDll, "hwnd", "BeginBufferedPaint", "hwnd", $hDC, "ptr", $pRc, "int", $iBufferFormat, "ptr", $pPaintParams, "ptr", DllStructGetPtr($tHDC)) If @error Then Return SetError(@error, @extended, 0) $phDC = DllStructGetData($tHDC, 1) Return SetError(0, 0, $aResult[0]) EndFunc Func _WinAPI_EndBufferedPaint($hPaintBuffer, $fUpdateTarget = True, $hDll = "uxtheme.dll") Local $aResult = DllCall($hDll, "int", "EndBufferedPaint", "hwnd", $hPaintBuffer, "int", $fUpdateTarget) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, $aResult[0], $aResult[0] = 0) EndFunc Func _WinAPI_BufferedPaintSetAlpha($hPaintBuffer, $pRc, $bAlpha = 255, $hDll = "uxtheme.dll") Local $aResult = DllCall($hDll, "int", "BufferedPaintSetAlpha", "hwnd", $hPaintBuffer, "ptr", $pRc, "ubyte", $bAlpha) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, $aResult[0], $aResult[0] = 0) EndFuncThere are a lot of more Glass effect scripts - search for it!Br,UEZ Edited December 9, 2012 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
FireFox Posted December 9, 2012 Posted December 9, 2012 @UEZ Nice! But there is still black corners on the button.
UEZ Posted December 9, 2012 Posted December 9, 2012 I modified the code (kudos to Authenticity)! Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
FireFox Posted December 9, 2012 Posted December 9, 2012 (edited) I modified the code (kudos to Authenticity)!Still a 1px white border Edited December 9, 2012 by FireFox
E1M1 Posted December 10, 2012 Author Posted December 10, 2012 (edited) Very nice. However edit looks a little ugly: expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) If Not IsDeclared("WM_DWMCOMPOSITIonchangeD") Then Global Const $WM_DWMCOMPOSITIonchangeD = 0x031E If Not IsDeclared("tagBP_PAINTPARAMS") Then Global Const $tagBP_PAINTPARAMS = "uint Size;uint Flags;" & $tagRECT & ";ptr BlendFunction;" If Not IsDeclared("tagPAINTSTRUCT") Then Global Const $tagPAINTSTRUCT = "hwnd hDC;int Erase;" & $tagRECT & ";int Restore;int IncUpdate;ubyte Reserved[32]" Global Enum $BPBF_COMPATIBLEBITMAP, $BPBF_DIB, $BPBF_TOPDOWNDIB, $BPBF_TOPDOWNMONODIB Global Const $PRF_CLIENT = 0x00000004 Global $hUxTheme = DllOpen("uxtheme.dll") Global $hGUI = GUICreate("Test", 200, 100) Global $iBtn = GUICtrlCreateButton("Test", 20, 20, 100, 40) Global $hBtn = GUICtrlGetHandle(-1) Global $iEdit = GUICtrlCreateEdit("aaa",20,45) Global $hEdit = GUICtrlGetHandle(-1) Global $hCtrlProc = DllCallbackRegister("_CtrlProc", "int", "hwnd;uint;wparam;lparam") Global $hWndProc = _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, DllCallbackGetPtr($hCtrlProc)) Global $hWndProc = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($hCtrlProc)) GUIRegisterMsg($WM_ERASEBKGND, "_WM_ERASEBKGND") GUIRegisterMsg($WM_DWMCOMPOSITIonchangeD, "_WM_DWMCOMPOSITIonchangeD") _SendMessage($hGUI, $WM_DWMCOMPOSITIonchangeD) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _WinAPI_SetWindowLong($hBtn, $GWL_WNDPROC, $hWndProc) _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $hWndProc) DllCallbackFree($hCtrlProc) GUIDelete() DllClose($hUxTheme) Exit Func _CtrlProc($hWnd, $iMsg, $iwParam, $ilParam) Local $hDC, $hBufferedDC, $hPaintBuffer Local $tPS, $pPS Local $tRect Switch $iMsg Case $WM_PAINT $tPS = DllStructCreate($tagPAINTSTRUCT) $pPS = DllStructGetPtr($tPS) $hDC = _WinAPI_BeginPaint($hWnd, $pPS) $tRect = DllStructCreate($tagRECT) For $i = 1 To 4 DllStructSetData($tRect, $i, DllStructGetData($tPS, $i+2)) Next $hPaintBuffer = _WinAPI_BeginBufferedPaint($hDC, DllStructGetPtr($tRect), $BPBF_TOPDOWNDIB, 0, $hBufferedDC, $hUxTheme) _SendMessage($hWnd, $WM_PRINTCLIENT, $hBufferedDC, $PRF_CLIENT) _WinAPI_BufferedPaintSetAlpha($hPaintBuffer, 0, 255, $hUxTheme) If $hPaintBuffer Then _WinAPI_EndBufferedPaint($hPaintBuffer, True, $hUxTheme) _WinAPI_EndPaint($hWnd, $pPS) Return 0 EndSwitch Return _WinAPI_CallWindowProc($hWndProc, $hWnd, $iMsg, $iwParam, $ilParam) EndFunc Func _WM_ERASEBKGND($hWnd, $iMsg, $iwParam, $ilParam) Local $hDC = $iwParam Local $tClientRect = _WinAPI_GetClientRect($hWnd) Local $hBrush = _WinAPI_GetStockObject($BLACK_BRUSH) _WinAPI_FillRect($hDC, DllStructGetPtr($tClientRect), $hBrush) _WinAPI_DeleteObject($hBrush) Return 1 EndFunc Func _WM_DWMCOMPOSITIonchangeD($hWnd, $iMsg, $iwParam, $ilParam) Local $tMargs = DllStructCreate($tagMARGINS) If _WinAPI_DwmIsCompositionEnabled() Then For $i = 1 To 4 DllStructSetData($tMargs, $i, -1) Next _WinAPI_DwmExtendFrameIntoClientArea($hWnd, $tMargs) EndIf Return 0 EndFunc Func _WinAPI_DwmExtendFrameIntoClientArea($hWnd, ByRef $tMargins) Local $aResult = DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", DllStructGetPtr($tMargins)) If @error Then Return SetError(@error, @extended, -1) Return $aResult[0] EndFunc Func _WinAPI_DwmIsCompositionEnabled() Local $aResult = DllCall("dwmapi.dll", "int", "DwmIsCompositionEnabled", "int*", 0) If @error Then Return SetError(@error, @extended, -1) Return SetError($aResult[0], 0, $aResult[1]) EndFunc Func _WinAPI_BeginPaint($hWnd, $pPaintStruct) Local $aResult = DllCall("user32.dll", "hwnd", "BeginPaint", "hwnd", $hWnd, "ptr", $pPaintStruct) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, 0, $aResult[0]) EndFunc Func _WinAPI_EndPaint($hWnd, $pPaintStruct) Local $aResult = DllCall("user32.dll", "int", "EndPaint", "hwnd", $hWnd, "ptr", $pPaintStruct) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, 0, $aResult[0]) EndFunc Func _WinAPI_BeginBufferedPaint($hDC, $pRc, $iBufferFormat, $pPaintParams ,ByRef $phDC, $hDll = "uxtheme.dll") Local $tHDC = DllStructCreate("hwnd") Local $aResult = DllCall($hDll, "hwnd", "BeginBufferedPaint", "hwnd", $hDC, "ptr", $pRc, "int", $iBufferFormat, "ptr", $pPaintParams, "ptr", DllStructGetPtr($tHDC)) If @error Then Return SetError(@error, @extended, 0) $phDC = DllStructGetData($tHDC, 1) Return SetError(0, 0, $aResult[0]) EndFunc Func _WinAPI_EndBufferedPaint($hPaintBuffer, $fUpdateTarget = True, $hDll = "uxtheme.dll") Local $aResult = DllCall($hDll, "int", "EndBufferedPaint", "hwnd", $hPaintBuffer, "int", $fUpdateTarget) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, $aResult[0], $aResult[0] = 0) EndFunc Func _WinAPI_BufferedPaintSetAlpha($hPaintBuffer, $pRc, $bAlpha = 255, $hDll = "uxtheme.dll") Local $aResult = DllCall($hDll, "int", "BufferedPaintSetAlpha", "hwnd", $hPaintBuffer, "ptr", $pRc, "ubyte", $bAlpha) If @error Then Return SetError(@error, @extended, 0) Return SetError(0, $aResult[0], $aResult[0] = 0) EndFunc Edited December 10, 2012 by E1M1 edited
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