Hiho,
Anleitung
Spoiler anzeigen
;===============================================================================
;
; Function Name:
; _DrawTransparentEllipse
; Description:: Let you draw a transparent Ellipse
; Parameter(s):
; $hwnd - Handle of GUI to work on
; $x - Postion x of the Ellipse
; $y - Postion y of the Ellipse
; $w - Width of the Ellipse
; $h - Height of the Ellipse, If w=h it will be a circle.
; $Transparency - Set Transparancy of GUI ( optional )
; Requirement(s): The Styles $WS_EX_COMPOSITED $WS_EX_LAYERED
; Return Value(s): Returns a windows handle.
; Author(s): Greek, martin
; Example : Yes
;===============================================================================
;===============================================================================
;
; Function Name:
; _DrawTransparentRect
; Description:: Let you draw a transparent Rect
; Parameter(s):
; $hwnd - Handle of GUI to work on
; $x - Postion x of the Rect
; $y - Postion y of the Rect
; $w - Width of the Rect
; $h - Height of the Rect, If w=h it will be a square.
; $Transparency - Set Transparancy of GUI ( optional )
; Requirement(s): The Styles $WS_EX_COMPOSITED $WS_EX_LAYERED
; Return Value(s): Returns a windows handle.
; Author(s): Greek, martin
;===============================================================================
;===============================================================================
;
; Function Name:
; _DrawTransparentLine
; Description:: Let you draw a transparent Line
; Lines must be drawed first and can't used dynamical!!.
; Parameter(s):
; $hwnd - Handle of GUI to work on
; $x - Postion x of the Line
; $y - Postion y of the Line
; $length - length of the Line
; $course - course of the Line
; $pensize - The pensize, default is 2 ( optional )
; $Transparency - Set Transparancy of GUI ( optional )
; Requirement(s): Layered Windows ( $WS_EX_LAYERED )
; Return Value(s): ControlID of the Form
; Author(s): Greek, martin
;===============================================================================
;===============================================================================
;
; Function Name:
; _DeletTransparentForm
; Description:: Delet the Form
; Parameter(s):
; $Form - controlID/handle of the Form
; Return Value(s): Success: Returns 1.
; Failure: Returns 0.
; Author(s): Greek, martin
;===============================================================================
Include
Spoiler anzeigen
#include-once
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
Global Const $WS_EX_COMPOSITED = 0x2000000
[/autoit] [autoit][/autoit] [autoit]Func _DrawTransparentEllipse($hwnd, $x,$y,$w,$h,$Transparency=255)
$Child=GUICreate ( "", $w, $h, $x, $y, $WS_CHILD, -1, $hwnd )
_WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
GUISetBkColor ( 0xABCDEF, $Child )
_GuiRoundCorners ( $Child, 0, 0, $w, $h)
GUISetState()
Return $Child
EndFunc
Func _DeletTransparentForm ( $Form )
If IsHWnd($Form) Then
$a=GUIDelete($Form)
Return $a
Else
$b=GUICtrlDelete($Form)
Return $b
EndIf
EndFunc
Func _DrawTransparentRect($hwnd, $x,$y,$w,$h,$Transparency=255)
$Child=GUICreate ( "", $w, $h, $x, $y, $WS_CHILD, -1, $hwnd )
_WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
GUISetBkColor ( 0xABCDEF, $Child )
GUISetState()
Return $Child
EndFunc
Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
; progandy
If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03
If Not $isColorRef Then
$i_transcolor = Hex(String($i_transcolor), 6)
$i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
EndIf
Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
Select
Case @error
Return SetError(@error, 0, 0)
Case $Ret[0] = 0
Return SetError(4, _WinAPI_GetLastError(), 0)
Case Else
Return 1
EndSelect
EndFunc ;==>_WinAPI_SetLayeredWindowAttributes
Func _WinAPI_GetLastError()
Local $aResult
$aResult = DllCall("Kernel32.dll", "int", "GetLastError")
If @error Then Return SetError(@error, 0, 0)
Return $aResult[0]
EndFunc ;==>_WinAPI_GetLastError
Func _GuiRoundCorners($hWnd, $x1, $y1, $x3, $y3)
Local $pos, $ret, $ret2
$pos = WinGetPos($hWnd)
$ret = DllCall('gdi32.dll', 'long', 'CreateRoundRectRgn', 'long', $x1, 'long', $y1, 'long', $pos[2], 'long', $pos[3], 'long', $x3, 'long', $y3)
If $ret[0] Then
$ret2 = DllCall('user32.dll', 'long', 'SetWindowRgn', 'hwnd', $hWnd, 'long', $ret[0], 'int', 1)
If $ret2[0] Then
Return 1
Else
Return 0
EndIf
Else
Return 0
EndIf
EndFunc
Func _DrawTransparentLine($hwnd, $X,$Y,$length,$course,$pensize=2,$Transparency=255)
_WinAPI_SetLayeredWindowAttributes($hwnd, 0xABCDEF, $Transparency)
$g1=GUICtrlCreateGraphic($X,$Y,0,0)
GUICtrlSetGraphic($g1, $GUI_GR_PENSIZE, $pensize )
GUICtrlSetGraphic($g1, $GUI_GR_COLOR,0xABCDEF, 0xABCDEF)
GUICtrlSetGraphic($g1, $GUI_GR_LINE, $length, $course)
GUICtrlSetGraphic($g1, $GUI_GR_REFRESH)
GUICtrlSetGraphic($g1, $GUI_GR_LINE, 1, 1)
Return $g1
EndFunc
Beispiel
Spoiler anzeigen
#include <DrawTransparent.au3>
[/autoit] [autoit][/autoit] [autoit]Global $Count=300
Global $Ellipse[$Count], $j=1
$myGui=GUICreate ( "dynamic transparent test", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, BitOR ( $WS_EX_TOPMOST, $WS_EX_COMPOSITED, $WS_EX_LAYERED ) )
GUISetBkColor ( 0x000000 )
GUISetState ()
$Ellipse[0]=_DrawTransparentEllipse( $myGui, @DesktopWidth/2-200, @DesktopHeight/2-200, 400, 300 )
[/autoit] [autoit][/autoit] [autoit]For $i=1 To $Count-1 Step +1
$Ellipse[$i]=_DrawTransparentEllipse ( $myGui, @DesktopWidth/2-200-$i, @DesktopHeight/2-200, 400+$j, 300 )
GUIDelete ( $Ellipse[$i-1] )
$j+=2
Next
While 1
$msg=GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Edit: Update 2, Rect und Ellipse jetzt auch dynamisch!