Définit les attributs d'une fenêtre de type Layered
#include <WinAPISysWin.au3>
_WinAPI_SetLayeredWindowAttributes ( $hWnd, $iTransColor [, $iTransGUI = 255 [, $iFlags = 0x03 [, $bColorRef = False]]] )
$hWnd | Handle de la GUI à traiter |
$iTransColor | Couleur de transparence |
$iTransGUI | [optionnel] Intensité de transparence |
$iFlags | [optionnel] Flags. |
$bColorRef | [optionnel] Si True, $iTransColor est une valeur COLORREF (0x00bbggrr), sinon une couleur RGB |
Succès: | Retourne True |
Échec: | Retourne False, appelez _WinAPI_GetLastError() pour obtenir des informations sur l'erreur. |
_WinAPI_GetLastError, _WinAPI_GetLayeredWindowAttributes
Consultez SetLayeredWindowAttributes dans la librairie MSDN.
#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPISysWin.au3> #include <WindowsConstants.au3> Local $hGui = GUICreate("trans", 300, 400, -1, -1, -1, $WS_EX_LAYERED) GUICtrlCreateLabel("Ceci est le texte d'une GUI Layered transparente", 10, 10, 300, 20, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetTip(-1, "Cliquez sur le label pour déplacer la fenêtre layered") Local $idLayButt = GUICtrlCreateButton("Button", 10, 40, 40) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGui, 0x010101) GUISetState(@SW_SHOW) Local $hGuicontrol = GUICreate("ControlGUI", 400, 400, 100, 100) Local $idCheckTrans = GUICtrlCreateCheckbox("Couleur de transparence 0xABCDEF (Coché) Ou 0x010101", 10, 10) Local $idCheckBorder = GUICtrlCreateCheckbox("POPUP-Style", 10, 30) GUICtrlCreateLabel("Transparence pour la Gui Layered", 10, 50) Local $idSlTrans = GUICtrlCreateSlider(10, 70, 200, 30) GUICtrlSetLimit($idSlTrans, 255, 0) GUICtrlSetData(-1, 255) GUISetState(@SW_SHOW) Local $iColor, $iStyle, $iTranscolor, $iAlpha, $iInfo Local $aExtMsg = GUIGetMsg(1), $iMsg = $aExtMsg[0] While $iMsg <> $GUI_EVENT_CLOSE Switch $aExtMsg[1] Case $hGuicontrol Switch $iMsg Case $idCheckTrans, $idSlTrans ; Modifie les attributs de couleur et d'intensité de transparence $iColor = (BitAND(GUICtrlRead($idCheckTrans), $GUI_CHECKED) = $GUI_CHECKED ? 0xABCDEF : 0x010101) _WinAPI_SetLayeredWindowAttributes($hGui, $iColor, GUICtrlRead($idSlTrans)) Case $idCheckBorder $iStyle = (BitAND(GUICtrlRead($idCheckBorder), $GUI_CHECKED) = $GUI_CHECKED ? $WS_POPUP : $GUI_SS_DEFAULT_GUI) GUISetStyle($iStyle, -1, $hGui) EndSwitch Case $hGui If $iMsg = $idLayButt Then $iInfo = _WinAPI_GetLayeredWindowAttributes($hGui, $iTranscolor, $iAlpha) MsgBox($MB_SYSTEMMODAL, 'Layered GUI', "Bouton de la fenêtre layered cliqué" & @CRLF & "Information sur cette fenêtre: " & @CRLF & _ "Couleur de Transparence: " & $iTranscolor & @CRLF & _ "Alpha Value: " & $iAlpha & @CRLF & _ "LWA_COLORKEY: " & (BitAND($iInfo, $LWA_COLORKEY) = $LWA_COLORKEY) & @CRLF & _ "LWA_ALPHA: " & (BitAND($iInfo, $LWA_ALPHA) = $LWA_ALPHA)) EndIf EndSwitch $aExtMsg = GUIGetMsg(1) $iMsg = $aExtMsg[0] WEnd If $aExtMsg[1] = $hGui Then MsgBox($MB_SYSTEMMODAL, '', "Fermeture à partir de la GUI Layered") EndIf