Code : Tout sélectionner
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
_GDIPlus_Startup()
test(1, @ScriptDir&"\"&"Background1.png")
test(2, @ScriptDir&"\"&"Background2.png")
_GDIPlus_Shutdown()
Func test($n, $path)
; Création du fond
Global $background = GUICreate("Exemple n°"&$n&" : $background", 180, 50, Default, Default, $WS_POPUP, $WS_EX_LAYERED)
Local _
$image = _GDIPlus_ImageLoadFromFile($path), _
$context = _WinAPI_GetDC(0), _
$memory = _WinAPI_CreateCompatibleDC($context), _
$bitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($image), _
$object = _WinAPI_SelectObject($memory, $bitmap)
Local _
$point = DllStructCreate("struct;long X;long Y;endstruct"), _
$size = DllStructCreate("struct;long X;long Y;endstruct"), _
$source = DllStructCreate("struct;long X;long Y;endstruct"), _
$blend = DllStructCreate("byte Op;byte Flags;byte Alpha;byte Format")
DllStructSetData($point, "X", (@DesktopWidth-180)/2)
DllStructSetData($point, "Y", (@DesktopHeight-50)/2)
DllStructSetData($size, "X", 180)
DllStructSetData($size, "Y", 50)
DllStructSetData($blend, "Alpha", 255)
DllStructSetData($blend, "Format", 1)
_WinAPI_UpdateLayeredWindow($background, $context, DllStructGetPtr($point), DllStructGetPtr($size), $memory, DllStructGetPtr($source), 0, DllStructGetPtr($blend), 2)
_WinAPI_ReleaseDC(0, $context)
_WinAPI_SelectObject($memory, $object)
_WinAPI_DeleteObject($bitmap)
_WinAPI_DeleteDC($memory)
; Création des contrôles
Global $controls = GUICreate("Exemple n°"&$n&" : $controls", 180, 50, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $background)
GUISetFont(11, 800, 1, "Arial", $controls, 5)
; Antialiasing OK avec fond plein
Local $label_ok = GUICtrlCreateLabel("Test aliasing : OK", 20, 8, 140, 17)
GUICtrlSetColor($label_ok, 0xFF7777)
GUICtrlSetBkColor($label_ok, 0xF4FF8A)
; Antialiasing KO avec fond transparent
Local $label_ko = GUICtrlCreateLabel("Test aliasing : KO", 20, 25, 140, 17)
GUICtrlSetColor($label_ko, 0xFF7777)
GUICtrlSetBkColor($label_ko, $GUI_BKCOLOR_TRANSPARENT)
; Finalisation pour affichage
Local $transparent_color = 0x010203
GUISetBkColor($transparent_color, $controls)
_WinAPI_SetLayeredWindowAttributes($controls, $transparent_color)
; Affichage
GUISetState(@SW_SHOW, $background)
GUISetState(@SW_SHOW, $controls)
; Traitement
Local $stop = False
Do
Local $msg = GUIGetMsg()
If Not @error Then
Switch $msg
Case -3 ; $GUI_EVENT_CLOSE = -3
$stop = True
Case Else
; Rien
EndSwitch
EndIf
Until $stop
; Effacement
GUIDelete($controls)
GUIDelete($background)
EndFunc