Greek Posted March 18, 2009 Share Posted March 18, 2009 Hi expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GDIPlus.au3> HotKeySet ( "{ESC}", "_ende" ) _GDIPlus_Startup() $hGui = GUICreate("Rahmen", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255) GUICtrlCreateLabel( "", 0, 0, @DesktopWidth, @DesktopHeight ) GUICtrlSetBkColor(-1, 0xABCDEF) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGui) $Pinsel=_GDIPlus_PenCreate ( 0xFF0000FF, 20 ) _GDIPlus_GraphicsDrawArc ( $hGraphic, @DesktopWidth/2, @DesktopHeight/2, 70, 70, 180, 360, $Pinsel ) While 1 WEnd Func _ende() _GDIPlus_Shutdown() Exit 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 How can i delete _GDIPlus_GraphicsDrawArc ( $hGraphic, @DesktopWidth/2, @DesktopHeight/2, 70, 70, 180, 360, $Pinsel ) ? thx, Greek Link to comment Share on other sites More sharing options...
BigDod Posted March 18, 2009 Share Posted March 18, 2009 _GDIPlus_GraphicsDispose ($hGraphic) Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
weaponx Posted March 18, 2009 Share Posted March 18, 2009 You don't really "delete" per se, but instead you just redraw excluding that specific element. Link to comment Share on other sites More sharing options...
Greek Posted March 19, 2009 Author Share Posted March 19, 2009 _GDIPlus_GraphicsDispose ($hGraphic) Doesn't work, the arc is still there expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GDIPlus.au3> HotKeySet ( "{ESC}", "_ende" ) _GDIPlus_Startup() $hGui = GUICreate("Rahmen", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255) GUICtrlCreateLabel( "", 0, 0, @DesktopWidth, @DesktopHeight ) GUICtrlSetBkColor(-1, 0xABCDEF) GUISetState() $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGui) $Pinsel=_GDIPlus_PenCreate ( 0xFF0000FF, 20 ) _GDIPlus_GraphicsDrawArc ( $hGraphic, @DesktopWidth/2, @DesktopHeight/2, 70, 70, 180, 360, $Pinsel ) MsgBox ( 0, "", "..." ) _GDIPlus_GraphicsDispose ($hGraphic) While 1 WEnd Func _ende() _GDIPlus_Shutdown() Exit 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 Shellexecute (@MyDocumentsDir & "\Eigene Musik\musik.m3u") ShellExecute ( "musik.m3u", "", @MyDocumentsDir & "\Eigene Musik" ) Link to comment Share on other sites More sharing options...
Greek Posted March 19, 2009 Author Share Posted March 19, 2009 You don't really "delete" per se, but instead you just redraw excluding that specific element.I don't understand... can you make an example? Link to comment Share on other sites More sharing options...
martin Posted March 19, 2009 Share Posted March 19, 2009 I don't understand... can you make an example? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <timers.au3> HotKeySet("{ESC}", "_ende") _GDIPlus_Startup() Global $hGui = GUICreate("Rahmen", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255) GUICtrlCreateLabel("", 0, 0, @DesktopWidth, @DesktopHeight) GUICtrlSetBkColor(-1, 0xABCDEF) GUISetState() $seg = 0 Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) $Pinsel = _GDIPlus_PenCreate(0xFF0000FF, 20) Global $vanish = _GDIPlus_PenCreate(0xFFfffffF, 20) ;_GDIPlus_GraphicsDrawArc ( $hGraphic, @DesktopWidth/2, @DesktopHeight/2, 70, 70, 180, 360, $Pinsel ) $t1 = _Timer_SetTimer(0, 300, "remove") MsgBox ( 0, "", "..." ) _Timer_KillTimer(0, $t1) While 1 Sleep(40) WEnd _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BrushDispose($Pinsel) _GDIPlus_BrushDispose($vanish) Func _ende() _GDIPlus_Shutdown() Exit EndFunc ;==>_ende Func remove($a, $b, $c, $d) _GDIPlus_GraphicsDrawArc($hGraphic, @DesktopWidth / 2, @DesktopHeight / 2, 70, 70, $seg * 30, 30, $vanish) $seg += 1 _GDIPlus_GraphicsDrawArc($hGraphic, @DesktopWidth / 2, @DesktopHeight / 2, 70, 70, $seg * 30, 30, $Pinsel) EndFunc ;==>remove 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 ;Shellexecute (@MyDocumentsDir & "\Eigene Musik\musik.m3u") ;ShellExecute ( "musik.m3u", "", @MyDocumentsDir & "\Eigene Musik" ) Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Greek Posted March 19, 2009 Author Share Posted March 19, 2009 (edited) Wow nice, but could you tell why this doesn't work? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <timers.au3> HotKeySet("{ESC}", "_ende") Global $ballpos1=@DesktopWidth/2 Global $ballpos2=@DesktopHeight/2 Global $BewegungSenkrecht=Random(5, 7, 1) Global $BewegungWagrecht=Random(5, 7, 1) Global $Speed=10 _GDIPlus_Startup() Global $hGui = GUICreate("Rahmen", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255) GUISetState() Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) $Pinsel = _GDIPlus_PenCreate(0xFF0000FF, 20) Global $vanish = _GDIPlus_PenCreate(0xFFfffffF, 20) ;_GDIPlus_GraphicsDrawArc ( $hGraphic, @DesktopWidth/2, @DesktopHeight/2, 70, 70, 180, 360, $Pinsel ) $t1 = _Timer_SetTimer(0, 300, "move") While 1 Sleep(40) WEnd _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BrushDispose($Pinsel) _GDIPlus_BrushDispose($vanish) Func _ende() _GDIPlus_Shutdown() Exit EndFunc ;==>_ende Func move($a, $b, $c, $d) _GDIPlus_GraphicsDrawArc ( $hGraphic, $ballpos1, $ballpos2, 70, 70, 180, 360, $vanish ) $ballpos1+=$BewegungWagrecht * $Speed $ballpos2+=$BewegungSenkrecht * $Speed _GDIPlus_GraphicsDrawArc ( $hGraphic, $ballpos1, $ballpos2, 70, 70, 180, 360, $Pinsel ) If $ballpos1 >= @DesktopWidth - 80 And $BewegungWagrecht > 0 Then $BewegungWagrecht = Random(-7, -5, 1) If $ballpos1 < 10 And $BewegungWagrecht < 0 Then $BewegungWagrecht = Random(5, 7, 1) If $ballpos2 >= @DesktopHeight - 95 And $BewegungSenkrecht > 0 Then $BewegungSenkrecht = Random(-7, -5, 1) If $ballpos2 < 30 And $BewegungSenkrecht < 0 Then $BewegungSenkrecht = Random(5, 7, 1) EndFunc ;==>move 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 Edit: lol, no your Script doesn't work too don't understand this... Edited March 19, 2009 by Greek Link to comment Share on other sites More sharing options...
martin Posted March 19, 2009 Share Posted March 19, 2009 I'm afraid I don't know. Transparent layered windows don't behave as I thought and drawing with GDIPlus in the transparent colour doesn't produce a transparent effect but simply draws the 'transparent' colour. It needs someone with a better understanding than I have at the moment. If the ring is the only thing you want to show then it would be easier to have a small window which is trasparent just big enough to hold the ring and then move the wondow around rather than redraw the ring. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Malkey Posted March 19, 2009 Share Posted March 19, 2009 GreekBecause your GUI is desktop size, every time the blue arc is replaced with a white arc, the white arc remains on the GUI.Replace _GDIPlus_GraphicsDrawArc ( $hGraphic, $ballpos1, $ballpos2, 70, 70, 180, 360, $vanish )with_WinAPI_RedrawWindow($hGui)hereFunc move($a, $b, $c, $d) _WinAPI_RedrawWindow($hGui) $ballpos1+=$BewegungWagrecht * $SpeedThis removes the white arcs.Here is another way of doing it.Originally this example was to show the removal of the existing graphics by pressing Ctrl button - still works.The graphics is on a layered GUI with a size slightly larger than the graphics to be displayed.It is the transparent GUI which is moving across the desktop.The _WinMove() function is not necessary. It is difficult to click on the graphical part of the GUI to actually move it.expandcollapse popup#include <GDIPlus.au3> #include <GuiConstantsEx.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <timers.au3> Global Const $iOpacity = 255 ;Global Const $ULW_ALPHA = 2 Global $hGui, $hGraphic, $blueBrush, $hImage2, $iPath Global $dll = DllOpen("user32.dll") Global $GuiSize = 100, $hWnd, $hDC, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend Global Const $WM_LBUTTONDOWN = 0x0201; Drag Window 1 of 3 addin Global $t1 Global $ballpos1 = @DesktopWidth / 2 Global $ballpos2 = @DesktopHeight / 2 Global $BewegungSenkrecht = Random(5, 7, 1) Global $BewegungWagrecht = Random(5, 7, 1) Global $Speed = 10 Opt("MustDeclareVars", 1) Opt("GUIOnEventMode", 1) Main() Func Main() Local $hBitmap, $Pinsel, $flg = True $hGui = GUICreate("L1", $GuiSize, $GuiSize, -1, -1, 0, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUIRegisterMsg($WM_LBUTTONDOWN, "_WinMove"); Drag Window 2 of 3 addin GUISetState() _GDIPlus_Startup() $hWnd = _WinAPI_GetDC(0) $hDC = _WinAPI_CreateCompatibleDC($hWnd) $hBitmap = _WinAPI_CreateCompatibleBitmap($hWnd, $GuiSize, $GuiSize); $iWidth, $iHeight) _WinAPI_SelectObject($hDC, $hBitmap) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) ;$iPath = "C:\file.png" ;$hImage2 = _GDIPlus_ImageLoadFromFile($iPath) $Pinsel = _GDIPlus_PenCreate(0xFF0000FF, 20) _GDIPlus_GraphicsDrawArc($hGraphic, 10, 10, $GuiSize - 20, $GuiSize - 20, 180, 360, $Pinsel) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $GuiSize);$iWidth ) DllStructSetData($tSize, "Y", $GuiSize);$iHeight) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGui, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA) $t1 = _Timer_SetTimer(0, 300, "move") Do If _IsPressed("11") Then; CTRL key Do Sleep(10) Until Not _IsPressed("11") If $flg Then _GDIPlus_GraphicsClear($hGraphic) _GDIPlus_GraphicsDrawArc($hGraphic, 10, 10, $GuiSize - 20, $GuiSize - 20, 180, 180, $Pinsel) _WinAPI_UpdateLayeredWindow($hGui, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA) Else _GDIPlus_GraphicsClear($hGraphic) _GDIPlus_GraphicsDrawArc($hGraphic, 10, 10, $GuiSize - 20, $GuiSize - 20, 180, 360, $Pinsel) _WinAPI_UpdateLayeredWindow($hGui, $hWnd, 0, $pSize, $hDC, $pSource, 0, $pBlend, $ULW_ALPHA) EndIf $flg = Not $flg EndIf Sleep(10) Until _IsPressed("1B"); ESC key DllClose($dll) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_ReleaseDC(0, $hWnd) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hDC) _GDIPlus_Shutdown() EndFunc ;==>Main Func move($a, $b, $c, $d) $ballpos1 += $BewegungWagrecht * $Speed $ballpos2 += $BewegungSenkrecht * $Speed WinMove($hGui, "", $ballpos1, $ballpos2) If $ballpos1 >= @DesktopWidth - $GuiSize And $BewegungWagrecht > 0 Then $BewegungWagrecht = Random(-7, -5, 1) If $ballpos1 < 10 And $BewegungWagrecht < 0 Then $BewegungWagrecht = Random(5, 7, 1) If $ballpos2 >= @DesktopHeight - 95 And $BewegungSenkrecht > 0 Then $BewegungSenkrecht = Random(-7, -5, 1) If $ballpos2 < 30 And $BewegungSenkrecht < 0 Then $BewegungSenkrecht = Random(5, 7, 1) EndFunc ;==>move ; ================================================================= ; Drag Window 3 of 3 addin ; ================================================================= Func _WinMove($hWnd, $Command, $wParam, $lParam) If BitAND(WinGetState($hWnd), 32) Then Return $GUI_RUNDEFMSG ;DllCall("user32.dll", "long", "SendMessage", "hwnd", $HWnd, "int", $WM_SYSCOMMAND, "int", 0xF009, "int", 0) DllCall("user32.dll", "int", "SendMessage", "hWnd", $hWnd, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) EndFunc ;==>_WinMove Link to comment Share on other sites More sharing options...
Greek Posted March 20, 2009 Author Share Posted March 20, 2009 hm ok, hard to find a good solution for this :S thx, Greek Link to comment Share on other sites More sharing options...
martin Posted March 20, 2009 Share Posted March 20, 2009 @Malkey Can you tell me what a 'handle to the update region' is for the third parameter of the RedrawWindow function? I don't understand why the colour doesn't appear as transparent for the layered window. If I draw a rectangle filled with green say, and then draw a line through it with the transparent colour then the line is transparent as I expected, but when I draw the circle in the transoarent colour over the old circle it shows as the colour and not transparent. The size of the window doesn't affect this. If you can explain I would be grateful. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Greek Posted March 20, 2009 Author Share Posted March 20, 2009 (edited) A i have another question: This code works fine: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <timers.au3> HotKeySet("{ESC}", "_ende") Global $ballpos1=@DesktopWidth/2 Global $ballpos2=@DesktopHeight/2 Global $BewegungSenkrecht=Random(5, 7, 1) Global $BewegungWagrecht=Random(5, 7, 1) Global $Speed=10 _GDIPlus_Startup() Global $hGui = GUICreate("Rahmen", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255) GUISetState() Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) $Pinsel = _GDIPlus_PenCreate(0xFF0000FF, 20) Global $vanish = _GDIPlus_PenCreate(0xFF000000, 20) $t1 = _Timer_SetTimer(0, 10, "move") $begin=TimerInit() While 1 Sleep(40) WEnd _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BrushDispose($Pinsel) _GDIPlus_BrushDispose($vanish) Func _ende() _GDIPlus_Shutdown() Exit EndFunc ;==>_ende Func move($a, $b, $c, $d) _GDIPlus_GraphicsDrawLine ( $hGraphic, $ballpos1, $ballpos2, $ballpos1+50, $ballpos2+50, $vanish ) $ballpos1+=$BewegungWagrecht * $Speed $ballpos2+=$BewegungSenkrecht * $Speed _GDIPlus_GraphicsDrawLine ( $hGraphic, $ballpos1, $ballpos2, $ballpos1+50, $ballpos2+50, $Pinsel ) If $ballpos1 >= @DesktopWidth - 80 And $BewegungWagrecht > 0 Then $BewegungWagrecht = Random(-7, -5, 1) If $ballpos1 < 10 And $BewegungWagrecht < 0 Then $BewegungWagrecht = Random(5, 7, 1) If $ballpos2 >= @DesktopHeight - 95 And $BewegungSenkrecht > 0 Then $BewegungSenkrecht = Random(-7, -5, 1) If $ballpos2 < 30 And $BewegungSenkrecht < 0 Then $BewegungSenkrecht = Random(5, 7, 1) If _GDIPlus_PenGetColor ( $vanish )=0xFF000000 Then _GDIPlus_PenSetColor ( $vanish, 0xFFFFFF00 ) ElseIf _GDIPlus_PenGetColor ( $vanish )=0xFFFFFF00 Then _GDIPlus_PenSetColor ( $vanish, 0xFFFF0000 ) ElseIf _GDIPlus_PenGetColor ( $vanish )=0xFFFF0000 Then _GDIPlus_PenSetColor ( $vanish, 0xFF00FF00 ) ElseIf _GDIPlus_PenGetColor ( $vanish )=0xFF00FF00 Then _GDIPlus_PenSetColor ( $vanish, 0xFF000000 ) EndIf ;~ $dif=TimerDiff( $begin ) ;~ If $dif>12000 Then ;~ _GDIPlus_GraphicsClear ( $hGraphic, 0xFFABCDEF ) ;~ $begin=TimerInit() ;~ EndIf EndFunc ;==>move 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_SetLayeredWindowAttributesoÝ÷ Øø®±çb¶Þ¯bë"q©÷ö×%¢Ç¢·D¢H¢éÝjÊ%ºØ¨«¢+Ø¥¹±Õ±ÐíU% ½¹ÍѹÑÍà¹ÔÌÐì(¥¹±Õ±Ðí]¥¹½ÝÍ ½¹ÍѹÑ̹ÔÌÐì(¥¹±Õ±Ðí%A±Õ̹ÔÌÐì(¥¹±Õ±ÐíÑ¥µÉ̹ÔÌÐì(¥¹±Õ±Ðí5¥Í¹ÔÌÐì((ÀÌØí±°ô±±=Á¸ ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì¤()±½°ÀÌØí±±Á½ÌÄõÍѽÁ]¥Ñ ¼È)±½°ÀÌØí±±Á½ÌÈõÍѽÁ!¥¡Ð¼È)±½°ÀÌØí ÝÕ¹M¹É¡ÐõI¹½´ ԰ܰĤ)±½°ÀÌØí ÝÕ¹]É¡ÐõI¹½´ ԰ܰĤ)±½°ÀÌØíMÁôÄÀ()}%A±ÕÍ}MÑÉÑÕÀ ¤()±½°ÀÌØí¡Õ¤ôU% ÉÑ ÅÕ½ÐíI¡µ¸ÅÕ½Ðì°ÍѽÁ]¥Ñ °ÍѽÁ!¥¡Ð°´Ä°´Ä°ÀÌØí]M}A=AU@°ÀÌØí]M}a}1eI¤)U%MÑ ½±½È Áá ¤)}]¥¹A%}MÑ1åÉ]¥¹½ÝÑÑÉ¥ÕÑÌ ÀÌØí¡Õ¤°Áá °ÈÔÔ¤)U%MÑMÑÑ ¤)±½°ÀÌØí¡ÉÁ¡¥ô}%A±ÕÍ}ÉÁ¡¥Í ÉÑɽµ!]9 ÀÌØí¡Õ¤¤(ÀÌØíA¥¹Í°ô}%A±ÕÍ}A¹ ÉÑ ÁáÀÀÀÁ°ÈÀ¤)±½°ÀÌØíÙ¹¥Í ô}%A±ÕÍ}A¹ ÉÑ ÁáÀÀÀÀÀÀ°ÈÀ¤(ÀÌØíÐÄô}Q¥µÉ}MÑQ¥µÈ À°ÄÀ°ÅÕ½Ðíµ½ÙÅÕ½Ðì¤(ÀÌØí¥¸õQ¥µÉ%¹¥Ð ¤()±¥¹± ÅÕ½Ðí}¡¬ÅÕ½Ðì°ÔÀ¤()]¡¥±Ä($ÀÌØí¹µÍõU%Ñ5Í ¤(%MÝ¥Ñ ÀÌØí¹µÍ($% ÍÀÌØíÕ¥}Ù¹Ñ}±½Í($$%á¥Ð(%¹MÝ¥Ñ )]¹(()Õ¹}¹ ¤(%}%A±ÕÍ}A¹¥ÍÁ½Í ÀÌØíA¥¹Í°¤(}%A±ÕÍ}A¹¥ÍÁ½Í ÀÌØíÙ¹¥Í ¤(%}%A±ÕÍ}ÉÁ¡¥Í¥ÍÁ½Í ÀÌØí¡ÉÁ¡¥¤(}%A±ÕÍ}M¡Õѽݸ ¤(á¥Ð)¹Õ¹ìôôÐí}¹()Õ¹µ½Ù ÀÌØí°ÀÌØí°ÀÌØí°ÀÌØí¤(}%A±ÕÍ}ÉÁ¡¥ÍÉÝ1¥¹ ÀÌØí¡ÉÁ¡¥°ÀÌØí±±Á½ÌÄ°ÀÌØí±±Á½ÌÈ°ÀÌØí±±Á½ÌĬÔÀ°ÀÌØí±±Á½ÌȬÔÀ°ÀÌØíÙ¹¥Í ¤($ÀÌØí±±Á½ÌĬôÀÌØí ÝÕ¹]ɡШÀÌØíMÁ($ÀÌØí±±Á½ÌȬôÀÌØí ÝÕ¹M¹É¡Ð¨ÀÌØíMÁ(}%A±ÕÍ}ÉÁ¡¥ÍÉÝ1¥¹ ÀÌØí¡ÉÁ¡¥°ÀÌØí±±Á½ÌÄ°ÀÌØí±±Á½ÌÈ°ÀÌØí±±Á½ÌĬÔÀ°ÀÌØí±±Á½ÌȬÔÀ°ÀÌØíA¥¹Í°¤(%ÀÌØí±±Á½ÌÄÐìôÍѽÁ]¥Ñ ´àÀ¹ÀÌØí ÝÕ¹]É¡ÐÐìÀQ¡¸ÀÌØí ÝÕ¹]É¡ÐôI¹½´ ´Ü°´Ô°Ä¤(%ÀÌØí±±Á½ÌıÐìÄÀ¹ÀÌØí ÝÕ¹]ɡбÐìÀQ¡¸ÀÌØí ÝÕ¹]É¡ÐôI¹½´ ԰ܰĤ(%ÀÌØí±±Á½ÌÈÐìôÍѽÁ!¥¡Ð´äÔ¹ÀÌØí ÝÕ¹M¹É¡ÐÐìÀQ¡¸ÀÌØí ÝÕ¹M¹É¡ÐôI¹½´ ´Ü°´Ô°Ä¤(%ÀÌØí±±Á½ÌȱÐìÌÀ¹ÀÌØí ÝÕ¹M¹É¡Ð±ÐìÀQ¡¸ÀÌØí ÝÕ¹M¹É¡ÐôI¹½´ ԰ܰĤ(%%}%A±ÕÍ}A¹Ñ ½±½È ÀÌØíÙ¹¥Í ¤ôÁáÀÀÀÀÀÀQ¡¸(%}%A±ÕÍ}A¹MÑ ½±½È ÀÌØíÙ¹¥Í °ÁáÀÀ¤(±Í%}%A±ÕÍ}A¹Ñ ½±½È ÀÌØíÙ¹¥Í ¤ôÁáÀÀQ¡¸(%}%A±ÕÍ}A¹MÑ ½±½È ÀÌØíÙ¹¥Í °ÁáÀÀÀÀ¤(±Í%}%A±ÕÍ}A¹Ñ ½±½È ÀÌØíÙ¹¥Í ¤ôÁáÀÀÀÀQ¡¸(%}%A±ÕÍ}A¹MÑ ½±½È ÀÌØíÙ¹¥Í °ÁáÀÁÀÀ¤(±Í%}%A±ÕÍ}A¹Ñ ½±½È ÀÌØíÙ¹¥Í ¤ôÁáÀÁÀÀQ¡¸(%}%A±ÕÍ}A¹MÑ ½±½È ÀÌØíÙ¹¥Í °ÁáÀÀÀÀÀÀ¤(¹%(íøÀÌØí¥õQ¥µÉ¥ ÀÌØí¥¸¤(íø%%ÀÌØí¥ÐìÄÈÀÀÀQ¡¸(íø$%}%A±ÕÍ}ÉÁ¡¥Í ±È ÀÌØí¡ÉÁ¡¥°Áá ¤(íø$$ÀÌØí¥¸õQ¥µÉ%¹¥Ð ¤(íø%¹%)¹Õ¹ìôôÐíµ½Ù((()Õ¹}]¥¹A%}MÑ1åÉ]¥¹½ÝÑÑÉ¥ÕÑÌ ÀÌØí¡Ý¹°ÀÌØí¥}Ñɹͽ±½È°ÀÌØíQɹÍÁɹäôÈÔÔ°ÀÌØíݱÌôÁàÀÌ°ÀÌØí¥Í ½±½ÉIô±Í¤(ìÁɽ¹ä(%ÀÌØíݱÌôÕ±Ð=ÈÀÌØíݱÌôÅÕ½ÐìÅÕ½Ðì=ÈÀÌØíݱ̱ÐìÀQ¡¸ÀÌØíݱÌôÁàÀÌ(%9½ÐÀÌØí¥Í ½±½ÉIQ¡¸(ÀÌØí¥}Ñɹͽ±½Èô!à¡MÑÉ¥¹ ÀÌØí¥}Ñɹͽ±½È¤°Ø¤(ÀÌØí¥}Ñɹͽ±½ÈôáÕÑ ÌäìÁàÀÀÌäìµÀìMÑÉ¥¹5¥ ÀÌØí¥}Ñɹͽ±½È°Ô°È¤µÀìMÑÉ¥¹5¥ ÀÌØí¥}Ñɹͽ±½È°Ì°È¤µÀìMÑÉ¥¹5¥ ÀÌØí¥}Ñɹͽ±½È°Ä°È¤¤(¹%(1½°ÀÌØíIÐô±± ±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíMÑ1åÉ]¥¹½ÝÑÑÉ¥ÕÑÌÅÕ½Ðì°ÅÕ½Ðí¡Ý¹ÅÕ½Ðì°ÀÌØí¡Ý¹°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØí¥}Ñɹͽ±½È°ÅÕ½ÐíåÑÅÕ½Ðì°ÀÌØíQɹÍÁɹä°ÅÕ½Ðí±½¹ÅÕ½Ðì°ÀÌØíݱ̤(M±Ð( ÍÉɽÈ(IÑÕɸMÑÉɽȡÉɽȰÀ°À¤( ÍÀÌØíIÑlÁtôÀ(IÑÕɸMÑÉÉ½È Ð°}]¥¹A%}Ñ1ÍÑÉÉ½È ¤°À¤( ͱÍ(IÑÕɸÄ(¹M±Ð)¹Õ¹ìôôÐí}]¥¹A%}MÑ1åÉ]¥¹½ÝÑÑÉ¥ÕÑÌ()Õ¹}¡¬ ¤(%%}%ÍAÉÍÍ ÅÕ½ÐìÅÅÕ½Ðì°ÀÌØí±°¤Q¡¸(%}¹ ¤(%¹%)¹Õ¹ Edited March 20, 2009 by Greek Link to comment Share on other sites More sharing options...
Malkey Posted March 21, 2009 Share Posted March 21, 2009 @Malkey Can you tell me what a 'handle to the update region' is for the third parameter of the RedrawWindow function?martinThe third parameter of the RedrawWindow function, I believe, accepts the handles returned from_WinAPI_CreateRectRgn, _WinAPI_CreateRoundRectRgn wrappers or any of the "CreateTypeRgn" functions in gdi32.dll. I can not remember entering anything other than 0 in this third parameter. The only times I played around with regions which may require the RedrawWindow function, the region/s have been converted to a window handle with "SetWindowRgn".I don't understand why the colour doesn't appear as transparent for the layered window. If I draw a rectangle filled with green say, and then draw a line through it with the transparent colour then the line is transparent as I expected, but when I draw the circle in the transoarent colour over the old circle it shows as the colour and not transparent. The size of the window doesn't affect this. If you can explain I would be grateful.I think of a transparent colour as a colour with the alpha channel, AA equal to 00 in the hex colour format 0xAARRGGBB. With partial transparency, the alpha channel ranges between (1 to 254) or (0x01 to 0xFE), 0x00 being completely transparent and 0xFF being completely opaque.I think you are referring to an apparent transparent colour, where the graphic's colour used is the same as the background colour. Your question makes more sense, kind of.When you say the line through the green rectangle is transparent, do you mean you can not see the line, or, is there an etched invisible line showing the background colour through the green?Either way I look at the problem you stated, there seems to be conflicting results. An example may clarify things.The second example, draw circle on a circle, makes me think you need to use _WinAPI_UpdateLayeredWindow() to update the layered window. But the green rectangle example appears it is being updated.I don't know.Malkey Link to comment Share on other sites More sharing options...
martin Posted March 21, 2009 Share Posted March 21, 2009 (edited) martin The third parameter of the RedrawWindow function, I believe, accepts the handles returned from_WinAPI_CreateRectRgn, _WinAPI_CreateRoundRectRgn wrappers or any of the "CreateTypeRgn" functions in gdi32.dll. I can not remember entering anything other than 0 in this third parameter. The only times I played around with regions which may require the RedrawWindow function, the region/s have been converted to a window handle with "SetWindowRgn". I think of a transparent colour as a colour with the alpha channel, AA equal to 00 in the hex colour format 0xAARRGGBB. With partial transparency, the alpha channel ranges between (1 to 254) or (0x01 to 0xFE), 0x00 being completely transparent and 0xFF being completely opaque. I think you are referring to an apparent transparent colour, where the graphic's colour used is the same as the background colour. Your question makes more sense, kind of. When you say the line through the green rectangle is transparent, do you mean you can not see the line, or, is there an etched invisible line showing the background colour through the green? Either way I look at the problem you stated, there seems to be conflicting results. An example may clarify things. The second example, draw circle on a circle, makes me think you need to use _WinAPI_UpdateLayeredWindow() to update the layered window. But the green rectangle example appears it is being updated. I don't know. MalkeyThanks for your repl Malkey.Here is an example. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <timers.au3> #include <winapi.au3> HotKeySet("{ESC}", "_ende") Global $ballpos1=@DesktopWidth/2 Global $ballpos2=@DesktopHeight/2 Global $BewegungSenkrecht=Random(5, 7, 1) Global $BewegungWagrecht=Random(5, 7, 1) Global $Speed=10 _GDIPlus_Startup() Global $hGui = GUICreate("Rahmen", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xABCDEF) GUICtrlCreateLabel("",@DesktopWidth - 280,0,280,@DesktopHeight) GUICtrlSetBkColor(-1,0x555555) GUICtrlSetState(-1,$GUI_DISABLE) $BtnGreenRect = GUICtrlCreateButton("make green rect",@DesktopWidth - 240,80,180,20) $BtnTransParentRect = GUICtrlCreateButton("make 0xFFABCDEF rect",@DesktopWidth - 240,160,180,20) ;$BtnTransParentcircle = GUICtrlCreateButton("make 0xFFABCDEF circle",@DesktopWidth - 240,240,180,20) $BtnTransParentLine = GUICtrlCreateButton("make 0xFFABCDEF line",@DesktopWidth - 240,300,180,20) $BtnUpdate = GUICtrlCreateButton("update",@DesktopWidth - 240,380,180,20) $chkBox = GUICtrlCreateCheckbox("cover pen (else use brush)",@DesktopWidth - 240,460,180,20) $BtnDone = GUICtrlCreateButton("Exit",@DesktopWidth - 240,520,180,20) _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255) GUISetState() Global $paintarc = true Global $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui) Global $Pinsel = _GDIPlus_PenCreate(0xFF0000FF, 20) Global $vanish = _GDIPlus_PenCreate(0xFFABCDEF, 20) Global $hbrush1 = _GDIPlus_BrushCreateSolid(0xFFABCDEF) Global $hbrush2 = _GDIPlus_BrushCreateSolid(0xFF00FF00) ;_GDIPlus_GraphicsDrawArc ( $hGraphic, @DesktopWidth/2, @DesktopHeight/2, 70, 70, 180, 360, $Pinsel ) $t1 = _Timer_SetTimer(0, 300, "move") While 1 $msg = GUIGetMsg() switch $msg case $BtnGreenRect _GDIPlus_GraphicsFillRect($hGraphic, 1,100,@DesktopWidth - 280,300, $hBrush2) case $BtnTransParentRect _GDIPlus_GraphicsFillRect($hGraphic, 0,100,@DesktopWidth - 280,300, $hBrush1) case $BtnTransParentLine $v2 = _GDIPlus_PenCreate(0xFFABCDEF, 20);just in case something was going wrong with the $vanish pen _GDIPlus_GraphicsDrawLine($hGraphic, 0,0,@DesktopWidth - 280,@DesktopHeight, $v2) _GDIPlus_BrushDispose($v2) case $BtnUpdate _WinAPI_RedrawWindow($hGui) case $chkBox $paintarc = Not $paintarc Case $BtnDone _ende() EndSwitch WEnd Func _ende() _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_PenDispose($Pinsel) _GDIPlus_PenDispose($vanish) _GDIPlus_BrushDispose($hbrush1) _GDIPlus_BrushDispose($hbrush2) _GDIPlus_Shutdown() Exit EndFunc;==>_ende Func move($a, $b, $c, $d) if $paintarc then _GDIPlus_GraphicsDrawArc ( $hGraphic, $ballpos1, $ballpos2, 70, 70, 180, 360, $vanish ) Else _GDIPlus_GraphicsFillRect($hGraphic, $ballpos1-10, $ballpos2-10, 90, 90, $hBrush1) EndIf $ballpos1+=$BewegungWagrecht * $Speed $ballpos2+=$BewegungSenkrecht * $Speed _GDIPlus_GraphicsDrawArc ( $hGraphic, $ballpos1, $ballpos2, 70, 70, 180, 360, $Pinsel ) If $ballpos1 >= @DesktopWidth - 280 - 115 And $BewegungWagrecht > 0 Then $BewegungWagrecht = Random(-7, -5, 1) If $ballpos1 < 10 And $BewegungWagrecht < 0 Then $BewegungWagrecht = Random(5, 7, 1) If $ballpos2 >= @DesktopHeight - 95 And $BewegungSenkrecht > 0 Then $BewegungSenkrecht = Random(-7, -5, 1) If $ballpos2 < 30 And $BewegungSenkrecht < 0 Then $BewegungSenkrecht = Random(5, 7, 1) EndFunc;==>move 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 My question is "Why does the rectangle get shown correctly whether it is the transparent colour or not, when the arcs are not shown correctly if they are the transparent colour?" I don't think (believe) that _WinAPI_RedrawWindow($hGui) is really the correct function because all that does is to obliterate everything. It looks as though a pen is not shown as transparent but a brush is. As though the pen colour is not really the colour you think it is. ( I seem to have remembered incorrectly about the lines because they are the same as the arcs.) EDIT: I tried using GdipCreatePen2 but failedl. $vanish = DllCall($ghGDIPDll, "int", "GdipCreatePen2", "int",_WinAPI_GetStockObject($hbrush1), "int", 20, "int", 2, "int*", 0) $vanish = $vanish[0] doesn't work Anyone know how I should do it? Edited March 21, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Malkey Posted March 22, 2009 Share Posted March 22, 2009 My question is "Why does the rectangle get shown correctly whether it is the transparent colour or not, when the arcs are not shown correctly if they are the transparent colour?" I don't think (believe) that _WinAPI_RedrawWindow($hGui) is really the correct function because all that does is to obliterate everything. It looks as though a pen is not shown as transparent but a brush is. As though the pen colour is not really the colour you think it is. ( I seem to have remembered incorrectly about the lines because they are the same as the arcs.)I believe I found a solution. From here http://msdn.microsoft.com/en-us/library/2ha2ha35(VS.80).aspx and http://www.autoitscript.com/forum/index.ph...st&p=541838 The parameters for the user32.dll function, SetLayeredWindowAttributes are: ;hwnd -[in] Handle to the layered window. ;crKey - [in] COLORREF structure that specifies the transparency color key to be used when composing the layered window. ;bAlpha -[in] Alpha value used to describe the opacity of the layered window. ;dwFlags -[in] Specifies an action to take: LWA_COLORKEY, LWA_ALPHA If the colorKey only is to be used, change the dwFlags parameter to 0x01. So use _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255, 0x01) This link http://msdn.microsoft.com/en-us/library/ms997507.aspx has some good info about Layered Windows. Link to comment Share on other sites More sharing options...
martin Posted March 26, 2009 Share Posted March 26, 2009 I believe I found a solution. From here http://msdn.microsoft.com/en-us/library/2ha2ha35(VS.80).aspx and http://www.autoitscript.com/forum/index.ph...st&p=541838 The parameters for the user32.dll function, SetLayeredWindowAttributes are: ;hwnd -[in] Handle to the layered window. ;crKey - [in] COLORREF structure that specifies the transparency color key to be used when composing the layered window. ;bAlpha -[in] Alpha value used to describe the opacity of the layered window. ;dwFlags -[in] Specifies an action to take: LWA_COLORKEY, LWA_ALPHA If the colorKey only is to be used, change the dwFlags parameter to 0x01. So use _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF, 255, 0x01) This link http://msdn.microsoft.com/en-us/library/ms997507.aspx has some good info about Layered Windows.Thanks for looking at this Malkey. But I don't see how it can be connected with the layered window becuase drawing with a brush works correctly. Drawing on a layered window in the transparent colour produces a transparent effect if you use a brush but not if you use a pencil. Or maybe it's my (lack of) understanding of what a pencil is. I tried with the layered window dwFlags set to 0x01 but it made no difference. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
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