Was mache ich falsch!!
Das Udf funktioniert prima! aber Etwas stimmt nicht!!
Bitte um Hilfe
Spoiler anzeigen
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <windowsconstants.au3>
;===================================================================================================================================================================;
;========================================================================= Start Exemple ===========================================================================;
HotKeySet('{Esc}', '_Exit')
Global $icolor_red = 50, $icolor_green = 0, $icolor_blue = 100
$GuiTrans = GUICreate("", 500, 500, -1, -1, $WS_POPUPWINDOW, $WS_EX_LAYERED)
GUISetState()
_GDIPlus_Startup()
While 1
For $A = 0 To 5
Local $color = Changecolor()
_GDIPlusAnimateAlphaLabel($GuiTrans, "Press Esc to exit script" & @CRLF & "Press Esc to exit script", 50, 30, 400, 100, "Comic Sans MS", 20, $color, 0, 1, $A, 255, 20)
Sleep(500)
Next
WEnd
Func _Exit()
_GDIPlus_Shutdown()
Exit
EndFunc ;==>_Exit
Func Changecolor()
If $icolor_red < 255 Then
$icolor_red += 5
ElseIf $icolor_red = 255 Then
$icolor_red = 0
EndIf
If $icolor_green < 255 Then
$icolor_green += 5
ElseIf $icolor_green = 255 Then
$icolor_green = 0
EndIf
If $icolor_blue < 255 Then
$icolor_blue += 5
ElseIf $icolor_blue = 255 Then
$icolor_blue = 0
EndIf
ConsoleWrite("Color : " & Hex($icolor_red, 2) & Hex($icolor_green, 2) & Hex($icolor_blue, 2) & @CRLF)
Return Hex($icolor_red, 2) & Hex($icolor_green, 2) & Hex($icolor_blue, 2)
EndFunc ;==>Changecolor
;========================================================================= End Exemple =============================================================================;
;===================================================================================================================================================================;
; #FUNCTION# =======================================================================================================================================================;
;Name...........: GDIPlusAnimateAlphaLabel
; Description ...: Animate Alpha Label
; Syntax.........: DrawInsert($GUIID, $LString, $LX, $LY, $LabelWidth , $LabelHeight, $LFont = "Comic Sans MS", $LSize = 10, _
; $Lcol = "000000", $LFormat = 0, $LType = 0, $AnType = 0, $TransValue = 255, $AnSpeed = 20)
; Author ........: Spayrosam(GetDot)
;===================================================================================================================================================================;
Func _GDIPlusAnimateAlphaLabel($GUIID, $LString, $LX, $LY, $LabelWidth, $LabelHeight, $LFont = "Comic Sans MS", $LSize = 10, _
$Lcol = "000000", $LFormat = 0, $LType = 0, $AnType = 0, $TransValue = 255, $AnSpeed = 20)
If StringLeft($Lcol, 2) = "0x" Then $Lcol = StringTrimLeft($Lcol, 2)
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
Local $hBrush = _GDIPlus_BrushCreateSolid("0xFF" & $Lcol)
Local $hFormat = _GDIPlus_StringFormatCreate(0)
Local $hFamily = _GDIPlus_FontFamilyCreate($LFont)
Local $hFont = _GDIPlus_FontCreate($hFamily, $LSize, $LFormat)
Local $hLayout = _GDIPlus_RectFCreate($LX, $LY, 0, 0)
Local $aInfo = _GDIPlus_GraphicsMeasureString($Data[2], $LString, $hFont, $hLayout, $hFormat)
If $LType = 1 Then
Local $LabeltextResultW = DllStructGetData($aInfo[0], 3)
Local $LabeltextResultH = DllStructGetData($aInfo[0], 4)
Local $LabeltextResultN = DllStructGetData($aInfo[0], 1)
$LYNew = ($LabelHeight - $LabeltextResultH) / 2
$LXNew = ($LabelWidth - $LabeltextResultW) / 2
$hLayout = _GDIPlus_RectFCreate($LXNew, $LYNew, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($Data[2], $LString, $hFont, $hLayout, $hFormat)
EndIf
If $AnType = 0 Then
_GDIPlus_GraphicsDrawStringEx($Data[2], $LString, $hFont, $aInfo[0], $hFormat, $hBrush)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
ElseIf $AnType = 1 Then
For $DL = 0 To $LSize Step 1
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
Local $hFont = _GDIPlus_FontCreate($hFamily, $DL, $LFormat)
Local $aInfo = _GDIPlus_GraphicsMeasureString($Data[2], $LString, $hFont, $hLayout, $hFormat)
If $LType = 1 Then
Local $LabeltextResultW = DllStructGetData($aInfo[0], 3)
Local $LabeltextResultH = DllStructGetData($aInfo[0], 4)
$LYNew = ($LabelHeight - $LabeltextResultH) / 2
$LXNew = ($LabelWidth - $LabeltextResultW) / 2
$hLayout = _GDIPlus_RectFCreate($LXNew, $LYNew, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($Data[2], $LString, $hFont, $hLayout, $hFormat)
EndIf
_GDIPlus_GraphicsDrawStringEx($Data[2], $LString, $hFont, $aInfo[0], $hFormat, $hBrush)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
Sleep($AnSpeed)
Next
ElseIf $AnType = 2 Then
For $DL = $LSize To 0 Step -1
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
Local $hFont = _GDIPlus_FontCreate($hFamily, $DL, $LFormat)
Local $aInfo = _GDIPlus_GraphicsMeasureString($Data[2], $LString, $hFont, $hLayout, $hFormat)
If $LType = 1 Then
Local $LabeltextResultW = DllStructGetData($aInfo[0], 3)
Local $LabeltextResultH = DllStructGetData($aInfo[0], 4)
$LYNew = ($LabelHeight - $LabeltextResultH) / 2
$LXNew = ($LabelWidth - $LabeltextResultW) / 2
$hLayout = _GDIPlus_RectFCreate($LXNew, $LYNew, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($Data[2], $LString, $hFont, $hLayout, $hFormat)
EndIf
_GDIPlus_GraphicsDrawStringEx($Data[2], $LString, $hFont, $aInfo[0], $hFormat, $hBrush)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
Sleep($AnSpeed)
Next
ElseIf $AnType = 3 Then
Local $LStringAdd = ""
For $ANI = 1 To $LabeltextResultN Step 1
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
$LStringAdd = StringLeft($LString, $ANI)
_GDIPlus_GraphicsDrawStringEx($Data[2], $LStringAdd, $hFont, $aInfo[0], $hFormat, $hBrush)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
If $LStringAdd = $LString Then ExitLoop
Sleep($AnSpeed)
Next
ElseIf $AnType = 4 Then
Local $LStringDel = $LString
For $ANI = $LabeltextResultN To 0 Step -1
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
$LStringDel = StringTrimRight($LStringDel, 1)
_GDIPlus_GraphicsDrawStringEx($Data[2], $LStringDel, $hFont, $aInfo[0], $hFormat, $hBrush)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
If $LStringDel = "" Then ExitLoop
Sleep($AnSpeed)
Next
ElseIf $AnType = 5 Then
_GDIPlus_GraphicsDrawStringEx($Data[2], $LString, $hFont, $aInfo[0], $hFormat, $hBrush)
$CloneLabel = _GDIPlus_BitmapCloneArea($Data[1], 0, 0, $LabelWidth, $LabelHeight, $GDIP_PXF32ARGB)
$CloneLabel2 = _GDIPlus_BitmapCloneArea($Data[1], 0, 0, $LabelWidth, $LabelHeight, $GDIP_PXF32ARGB)
_GDIPlus_ImageRotateFlip($CloneLabel2, 4)
$valueRotateLabe = $LabelWidth / 20
For $ANI = $LabelWidth To 0 Step -$valueRotateLabe
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
$XRotateLabe = ($LabelWidth - $ANI) / 2
_GDIPlus_GraphicsDrawImageRect($Data[2], $CloneLabel, $XRotateLabe, 0, $ANI, $LabelHeight)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
Sleep($AnSpeed)
Next
For $ANI = 0 To $LabelWidth Step $valueRotateLabe
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
$XRotateLabe = ($LabelWidth - $ANI) / 2
_GDIPlus_GraphicsDrawImageRect($Data[2], $CloneLabel2, $XRotateLabe, 0, $ANI, $LabelHeight)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
Sleep($AnSpeed)
Next
For $ANI = $LabelWidth To 0 Step -$valueRotateLabe
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
$XRotateLabe = ($LabelWidth - $ANI) / 2
_GDIPlus_GraphicsDrawImageRect($Data[2], $CloneLabel2, $XRotateLabe, 0, $ANI, $LabelHeight)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
Sleep($AnSpeed)
Next
For $ANI = 0 To $LabelWidth Step $valueRotateLabe
$Data = _CreateGraphic($LabelWidth, $LabelHeight)
$XRotateLabe = ($LabelWidth - $ANI) / 2
_GDIPlus_GraphicsDrawImageRect($Data[2], $CloneLabel, $XRotateLabe, 0, $ANI, $LabelHeight)
_SetCleanGraphic($GUIID, $Data[1], $LabelWidth, $LabelHeight, $TransValue, $Data[0])
Sleep($AnSpeed)
Next
_WinAPI_DeleteObject($CloneLabel)
_WinAPI_DeleteObject($CloneLabel2)
EndIf
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
EndFunc ;==>_GDIPlusAnimateAlphaLabel
Func _CreateGraphic($GW, $GH)
Dim $ReturnData[3]
Global $Gui
$Graphics = _GDIPlus_GraphicsCreateFromHWND($Gui)
$hImageL = _GDIPlus_BitmapCreateFromGraphics($GW, $GH, $Graphics)
$hGraphicL = _GDIPlus_ImageGetGraphicsContext($hImageL)
$ReturnData[0] = $Graphics
$ReturnData[1] = $hImageL
$ReturnData[2] = $hGraphicL
Return $ReturnData
EndFunc ;==>_CreateGraphic
Func _SetCleanGraphic($IDLabel, $BitmapImage, $GW, $GH, $Trans, $CleanGraphics)
SetBitmap($IDLabel, $BitmapImage, $Trans, $GW, $GH)
_GDIPlus_GraphicsDispose($CleanGraphics)
_GDIPlus_BitmapDispose($BitmapImage)
EndFunc ;==>_SetCleanGraphic
Func _GDIPlus_ImageRotateFlip($hImage, $rfType)
Local $aResult
$aResult = DllCall($ghGDIPDll, "int", "GdipImageRotateFlip", "hwnd", $hImage, "long", $rfType)
If @error Then Return SetError(@error, @extended, False)
Return SetError($aResult[0], 0, $aResult[0] = 0)
EndFunc ;==>_GDIPlus_ImageRotateFlip
Func SetBitmap($hGUI, $hImage, $iOpacity, $iW, $iH)
Local $hScrDC = _WinAPI_GetDC(0)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
Local $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
Local $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$TSize = DllStructCreate("long X;long Y")
$pSize = DllStructGetPtr($TSize)
DllStructSetData($TSize, "X", $iW)
DllStructSetData($TSize, "Y", $iH)
$tSource = DllStructCreate("long X;long Y")
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate("byte Op;byte Flags;byte Alpha;byte Format")
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", $iOpacity)
DllStructSetData($tBlend, "Format", 1)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, 0x02)
_WinAPI_ReleaseDC(0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC($hMemDC)
EndFunc ;==>SetBitmap
Edit:
Bitte ändere zeile 75 bis 83. Sonst gibt es einen Fehler ($LType = 0)
If $LType = 1 Then
Local $LabeltextResultW = DllStructGetData($aInfo[0], 3)
Local $LabeltextResultH = DllStructGetData($aInfo[0], 4)
$LYNew = ($LabelHeight - $LabeltextResultH) / 2
$LXNew = ($LabelWidth - $LabeltextResultW) / 2
$hLayout = _GDIPlus_RectFCreate($LXNew, $LYNew, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($Data[2], $LString, $hFont, $hLayout, $hFormat)
EndIf
Local $LabeltextResultN = DllStructGetData($aInfo[0], 1)
Problem ist der CPU auslastung