• Hallo liebe AutoitCom,
    heute möchte ich euch mein neustes Script vorstellen - eine UDF Sammlung von Funktionen, mit denen es möglich ist, GDIPlus-Formen (z.B. Kreise, Rechtecke, Linien) als Objekte zu behandeln (leider ohne OOP).

    Features
    - Es lassen sich Objekte erstellen, die automatisch gezeichnet werden.
    - Automatisches Neuzeichnen dieser GDIPlus-Darstellungen
    - Integrierter Backbuffer
    - SmoothingMode
    - Klicks auf diese Objekte lassen sich in einem Array zurückgeben - ähnlich wie GuiGetMsg, nur mit GDIPlus-Formen.
    - Einfache Änderung von Farben und Texten.
    - Objekte:

    Objekte


    Rechteck (Msgrückgabe, farbige Füllfarbe, farbige Umrandung, definierbare Linienbreite)
    Dreieck (Msgrückgabe, farbige Füllfarbe, farbige Umrandung, definierbare Linienbreite)
    Polygon/Vieleck (Msgrückgabe, farbige Füllfarbe, farbige Umrandung, definierbare Linienbreite)
    Ellipse (Msgrückgabe, farbige Füllfarbe, farbige Umrandung, definierbare Linienbreite)
    String (Msgrückgabe, Schriftfarbe, definierbare Linienbreite, Schriftart, Format, Schriftgröße)
    Linie (Linienbreite, Linienfarbe)
    Bild (Msgrückgabe, farbige Umrandung, definierbare Linienbreite)


    Vorteile
    - Praktisch für Anfänger, da leicht zu verstehen
    - Kein Erstellen eines Buffers notwendig
    - Automatisches Neuzeichnen
    - Formen müssen nicht umständlich gemanaged werden
    - Klickrückgabe mit allen Objekten, die einen Mausklick abbekommen


    Nachteile
    - Schnelligkeit leidet evtl. ein wenig
    - nur eine Graphics / nur Zeichnen auf eine Gui ist momentan möglich.
    - ein mühvoller Klick auf den Download im Anhang ist notwendig


    Geplant
    Dieses Projekt wird nur weiter fortgeführt, wenn Interesse besteht (ansonsten evtl. wenn mir langweilig ist).
    - Kollisionscheck
    - Positionsänderungen der Objekte
    - mehrere Graphics
    - vorgefertigte Bewegungsabläufe für Objekte
    - Importieren weiterer Funktionen aus GDIPlus.au3
    - Schnelligkeit erhöhen
    - Verschiedene Berechnungen


    Umfang

    Funktionen
    [autoit]


    _GDIPlusObjekt_Startup
    _GDIPlusObjekt_GraphicsCreateFromHwnd
    _GDIPlusObjekt_DrawRect
    _GDIPlusObjekt_DrawTriangle
    _GDIPlusObjekt_DrawEllipse
    _GDIPlusObjekt_DrawEllipseByRadian
    _GDIPlusObjekt_DrawString
    _GDIPlusObjekt_DrawPolygon
    _GDIPlusObjekt_DrawLine
    _GDIPlusObjekt_DrawImage
    _GDIPlusObjekt_ChangeFillColor
    _GDIPlusObjekt_ChangeLineColor
    _GDIPlusObjekt_Delete
    _GDIPlusObjekt_SetStringText
    _GDIPlusObjekt_GetMsg
    _GDIPlusObjekt_Shutdown

    [/autoit]


    UDFs

    UDFs
    [autoit]


    #include-once
    #include <Array.au3>
    #include <GDIPlus.au3>
    #include <WinApi.au3>
    #include <Misc.au3>

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $__hGraphics
    Global $__bBuffer = False
    Global $__GUI
    Global $__hBitmap
    Global $__hBackbuffer
    Global $__iBkColor
    Global $__El = 10
    Global $__aObjekts[1][$__El]

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_Startup()
    ; Description ...: Starts up the GDI+ engine.
    ; Syntax ........: _GDIPlusObjekt_Startup()
    ; Parameters ....: None
    ; Return values .: Succesful: True (boolean)
    ; Unsuccesful: False (boolean)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: Same as _GDIPlus_Startup(). Must be used before other functions of the _GDIPlusObjekt.au3 are used.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_Startup()
    Return _GDIPlus_Startup()
    EndFunc ;==>_GDIPlusObjekt_Startup

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_GraphicsCreateFromHwnd
    ; Description ...: Creates a graphic-objekt other objekts can be drawed on.
    ; Syntax ........: _GDIPlusObjekt_GraphicsCreateFromHwnd($hWnd, $iBkColor, $bBuffer = False, $iSmoothingMode = 0)
    ; Parameters ....: $hWnd: Handle to the gui, where the graphic-objekts should be drawed on. (handle)
    ; $iBkColor: The backgroundcolor of the gui in argb. (argb-color)
    ; $bBuffer: True, if a backbuffer should be used. (boolean)
    ; $iSmoothingMode: Mode of the SmoothingMode. (0 = no smoothing, 1 = 8x4 filter, 2 = 8x8 filter) (integer)
    ; Return values .: None
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: No return value; only one graphic-objekt can be supported.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_GraphicsCreateFromHwnd($hWnd, $iBkColor, $bBuffer = False, $iSmoothingMode = 0)
    $__hGraphics = _GDIPlus_GraphicsCreateFromHWND($hWnd)
    $__GUI = $hWnd
    If $bBuffer = False Then
    $__bBuffer = False
    Else
    $__bBuffer = True
    $__hBitmap = _GDIPlus_BitmapCreateFromGraphics(_WinAPI_GetClientWidth($hWnd), _WinAPI_GetClientHeight($hWnd), $__hGraphics)
    $__hBackbuffer = _GDIPlus_ImageGetGraphicsContext($__hBitmap)
    EndIf
    $__iBkColor = $iBkColor
    _GDIPlus_GraphicsSetSmoothingMode($__hGraphics, $iSmoothingMode)
    GUIRegisterMsg(0x000F, "__GDIPLusObjekt_Redraw")
    EndFunc ;==>_GDIPlusObjekt_GraphicsCreateFromHwnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_DrawRect
    ; Description ...: Draws a rect with specific colors.
    ; Syntax ........: _GDIPlusObjekt_DrawRect($iX, $iY, $iWidth, $iHeight, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ; Parameters ....: $iX: X-coordinate of the left-top position of the rect. (integer)
    ; $iY: Y-coordinate of the left-top position of the rect. (integer)
    ; $iWidth: Width of the rect. (integer)
    ; $iHeight: Height of the rect. (integer)
    ; $iLineColor: Argb-color of the line of the rect. (False = no line) (argb-color)
    ; $iFillColor: Argb-fill-color of the rect. (False = not filled) (argb-color)
    ; $iLineWidth: Width of the line of the rect. (integer)
    ; Return values .: Returns an identifer for this rect. (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_DrawRect($iX, $iY, $iWidth, $iHeight, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ReDim $__aObjekts[UBound($__aObjekts, 1) + 1][$__El]
    $__aObjekts[UBound($__aObjekts, 1) - 1][0] = "Rect"
    $__aObjekts[UBound($__aObjekts, 1) - 1][1] = $iX
    $__aObjekts[UBound($__aObjekts, 1) - 1][2] = $iY
    $__aObjekts[UBound($__aObjekts, 1) - 1][3] = $iWidth
    $__aObjekts[UBound($__aObjekts, 1) - 1][4] = $iHeight
    $__aObjekts[UBound($__aObjekts, 1) - 1][5] = $iLineColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][6] = $iFillColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][7] = $iLineWidth
    __GDIPlusObjekt_Redraw()
    Return (UBound($__aObjekts, 1) - 1)
    EndFunc ;==>_GDIPlusObjekt_DrawRect

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_DrawTriangle
    ; Description ...: Draws a triangle with specific colors.
    ; Syntax ........: _GDIPlusObjekt_DrawRect($iX, $iY, $iWidth, $iHeight, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ; Parameters ....: $iX1: X-coordinate of the first point of the triangle. (integer)
    ; $iY1: Y-coordinate of the first point of the triangle. (integer)
    ; $iX2: X-coordinate of the second point of the triangle. (integer)
    ; $iY2: Y-coordinate of the second point of the triangle. (integer)
    ; $iX3: X-coordinate of the third point of the triangle. (integer)
    ; $iY3: Y-coordinate of the third point of the triangle. (integer)
    ; $iLineColor: Argb-color of the line of the triangle. (False = no line) (argb-color)
    ; $iFillColor: Argb-fill-color of the triangle. (False = not filled) (argb-color)
    ; $iLineWidth: Width of the line of the triangle. (integer)
    ; Return values .: Returns an identifer for this triangle. (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_DrawTriangle($iX1, $iY1, $iX2, $iY2, $iX3, $iY3, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ReDim $__aObjekts[UBound($__aObjekts, 1) + 1][$__El]
    $__aObjekts[UBound($__aObjekts, 1) - 1][0] = "Triangle"
    $__aObjekts[UBound($__aObjekts, 1) - 1][1] = $iX1
    $__aObjekts[UBound($__aObjekts, 1) - 1][2] = $iY1
    $__aObjekts[UBound($__aObjekts, 1) - 1][3] = $iX2
    $__aObjekts[UBound($__aObjekts, 1) - 1][4] = $iY2
    $__aObjekts[UBound($__aObjekts, 1) - 1][5] = $iX3
    $__aObjekts[UBound($__aObjekts, 1) - 1][6] = $iY3
    $__aObjekts[UBound($__aObjekts, 1) - 1][7] = $iLineColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][8] = $iFillColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][9] = $iLineWidth
    __GDIPlusObjekt_Redraw()
    Return (UBound($__aObjekts, 1) - 1)
    EndFunc ;==>_GDIPlusObjekt_DrawTriangle

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_DrawEllipse
    ; Description ...: Draws an ellipse with specific colors.
    ; Syntax ........: _GDIPlusObjekt_DrawEllipse($iX1, $iY1, $iWidth, $iHeight, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ; Parameters ....: $iX: X-coordinate of the left-top position of the ellipse. (integer)
    ; $iY: Y-coordinate of the left-top position of the ellipse. (integer)
    ; $iWidth: Width of the ellipse. (integer)
    ; $iHeight: Height of the ellipse. (integer)
    ; $iLineColor: Argb-color of the line of the ellipse. (False = no line) (argb-color)
    ; $iFillColor: Argb-fill-color of the ellipse. (False = not filled) (argb-color)
    ; $iLineWidth: Width of the line of the ellipse. (integer)
    ; Return values .: Returns an identifer for this ellipse. (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_DrawEllipse($iX1, $iY1, $iWidth, $iHeight, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ReDim $__aObjekts[UBound($__aObjekts, 1) + 1][$__El]
    $__aObjekts[UBound($__aObjekts, 1) - 1][0] = "Ellipse"
    $__aObjekts[UBound($__aObjekts, 1) - 1][1] = $iX1
    $__aObjekts[UBound($__aObjekts, 1) - 1][2] = $iY1
    $__aObjekts[UBound($__aObjekts, 1) - 1][3] = $iWidth
    $__aObjekts[UBound($__aObjekts, 1) - 1][4] = $iHeight
    $__aObjekts[UBound($__aObjekts, 1) - 1][5] = $iLineColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][6] = $iFillColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][7] = $iLineWidth
    __GDIPlusObjekt_Redraw()
    Return (UBound($__aObjekts, 1) - 1)
    EndFunc ;==>_GDIPlusObjekt_DrawEllipse

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_DrawEllipseByRadian
    ; Description ...: Draws an ellipse with specific colors.
    ; Syntax ........: _GDIPlusObjekt_DrawEllipseByRadian($iX1, $iY1, $iRadian, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ; Parameters ....: $iX: X-coordinate of the left-top position of the ellipse. (integer)
    ; $iY: Y-coordinate of the left-top position of the ellipse. (integer)
    ; $iRadian: Radian of the ellipse. (integer)
    ; $iLineColor: Argb-color of the line of the ellipse. (False = no line) (argb-color)
    ; $iFillColor: Argb-fill-color of the ellipse. (False = not filled) (argb-color)
    ; $iLineWidth: Width of the line of the ellipse. (integer)
    ; Return values .: Returns an identifer for this ellipse. (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_DrawEllipseByRadian($iX1, $iY1, $iRadian, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ReDim $__aObjekts[UBound($__aObjekts, 1) + 1][$__El]
    $__aObjekts[UBound($__aObjekts, 1) - 1][0] = "Ellipse"
    $__aObjekts[UBound($__aObjekts, 1) - 1][1] = $iX1
    $__aObjekts[UBound($__aObjekts, 1) - 1][2] = $iY1
    $__aObjekts[UBound($__aObjekts, 1) - 1][3] = ($iRadian * 2)
    $__aObjekts[UBound($__aObjekts, 1) - 1][4] = ($iRadian * 2)
    $__aObjekts[UBound($__aObjekts, 1) - 1][5] = $iLineColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][6] = $iFillColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][7] = $iLineWidth
    __GDIPlusObjekt_Redraw()
    Return (UBound($__aObjekts, 1) - 1)
    EndFunc ;==>_GDIPlusObjekt_DrawEllipseByRadian

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_DrawString
    ; Description ...: Draws a string with a specific color and a specific fonttype.
    ; Syntax ........: _GDIPlusObjekt_DrawString($iX1, $iY1, $sString, $iFontColor = 0xFF000000, $iFontSize = 10, $sFontType = "Arial", $iFormat = 0)
    ; Parameters ....: $iX: X-coordinate of the left-top position of the string. (integer)
    ; $iY: Y-coordinate of the left-top position of the string. (integer)
    ; $sString: String to draw. (string)
    ; $iFontColor: Argb-fontcolor of the string. (argb-color)
    ; $iFontSize: Fontsize of the string. (integer)
    ; $sFontType: Fonttype of the string. (integer)
    ; $iFormat: Format of the string. (integer)
    ; Return values .: Returns an identifer for this string. (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_DrawString($iX1, $iY1, $sString, $iFontColor = 0xFF000000, $iFontSize = 10, $sFontType = "Arial", $iFormat = 0)
    ReDim $__aObjekts[UBound($__aObjekts, 1) + 1][$__El]
    $__aObjekts[UBound($__aObjekts, 1) - 1][0] = "String"
    $__aObjekts[UBound($__aObjekts, 1) - 1][1] = $iX1
    $__aObjekts[UBound($__aObjekts, 1) - 1][2] = $iY1
    $__aObjekts[UBound($__aObjekts, 1) - 1][3] = __GDIPlusObjektGetFontSize("width", $sString, $sFontType, $iFontSize)
    $__aObjekts[UBound($__aObjekts, 1) - 1][4] = __GDIPlusObjektGetFontSize("height", $sString, $sFontType, $iFontSize)
    $__aObjekts[UBound($__aObjekts, 1) - 1][5] = $sString
    $__aObjekts[UBound($__aObjekts, 1) - 1][6] = $sFontType
    $__aObjekts[UBound($__aObjekts, 1) - 1][7] = $iFontColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][8] = $iFontSize
    $__aObjekts[UBound($__aObjekts, 1) - 1][9] = $iFormat
    __GDIPlusObjekt_Redraw()
    Return (UBound($__aObjekts, 1) - 1)
    EndFunc ;==>_GDIPlusObjekt_DrawString

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_DrawPolygon
    ; Description ...: Draws a polygon with a specific color and specific points .
    ; Syntax ........: _GDIPlusObjekt_DrawPolygon($aPoints, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ; Parameters ....: $aPoints: 2D-Array with points: [0][0] = number of points, [n][0] = x-coordinate, [n][1] = y-coordinate. (array/integer)
    ; $iLineColor: Argb-color of the line of the polygon. (argb-color)
    ; $iFillColor: Argb-fillcolor of the polygon. (argb-color)
    ; $iLineWidth: Width of the line of the polygon. (integer)
    ; Return values .: Returns an identifer for this string. (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: Last element of the array must be first point.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_DrawPolygon($aPoints, $iLineColor = 0xFF000000, $iFillColor = 0xFFFFFFFF, $iLineWidth = 2)
    ReDim $__aObjekts[UBound($__aObjekts, 1) + 1][$__El]
    $__aObjekts[UBound($__aObjekts, 1) - 1][0] = "Polygon"
    $__aObjekts[UBound($__aObjekts, 1) - 1][1] = $aPoints
    $__aObjekts[UBound($__aObjekts, 1) - 1][2] = $iLineColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][3] = $iFillColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][4] = $iLineWidth
    __GDIPlusObjekt_Redraw()
    Return (UBound($__aObjekts, 1) - 1)
    EndFunc ;==>_GDIPlusObjekt_DrawPolygon

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_DrawLine
    ; Description ...: Draws a line with specific colors.
    ; Syntax ........: _GDIPlusObjekt_DrawLine($iX1, $iY1, $iX2, $iY2, $iLineWidth = 1, $iLineColor = 0xFF000000)
    ; Parameters ....: $iX1: X-coordinate of the first position of the line. (integer)
    ; $iY1: Y-coordinate of the first position of the line. (integer)
    ; $iX2: X-coordinate of the second position of the line. (integer)
    ; $iY2: Y-coordinate of the second position of the line. (integer)
    ; $iLineWidth: Width of the line. (integer)
    ; $iLineColor: Argb-color of the line. (argb-color)
    ; Return values .: Returns an identifer for this line. (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: Returns no message at a _GDIPlusObjekt_GetMsg() call.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_DrawLine($iX1, $iY1, $iX2, $iY2, $iLineWidth = 1, $iLineColor = 0xFF000000)
    ReDim $__aObjekts[UBound($__aObjekts, 1) + 1][$__El]
    $__aObjekts[UBound($__aObjekts, 1) - 1][0] = "Line"
    $__aObjekts[UBound($__aObjekts, 1) - 1][1] = $iX1
    $__aObjekts[UBound($__aObjekts, 1) - 1][2] = $iY1
    $__aObjekts[UBound($__aObjekts, 1) - 1][3] = $iX2
    $__aObjekts[UBound($__aObjekts, 1) - 1][4] = $iY2
    $__aObjekts[UBound($__aObjekts, 1) - 1][5] = $iLineWidth
    $__aObjekts[UBound($__aObjekts, 1) - 1][6] = $iLineColor
    __GDIPlusObjekt_Redraw()
    Return (UBound($__aObjekts, 1) - 1)
    EndFunc ;==>_GDIPlusObjekt_DrawLine

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_DrawImage
    ; Description ...: Draws a image with specific colors and sizes.
    ; Syntax ........: _GDIPlusObjekt_DrawImage($iX, $iY, $sImagePath, $iWidth = -1, $iHeight = -1, $iLineColor = 0xFF000000, $iLineWidth = 2)
    ; Parameters ....: $iX: X-coordinate of the left-top position of the image. (integer)
    ; $iY: Y-coordinate of the left-top position of the image. (integer)
    ; $sImagePath: Path to the image. (string)
    ; $iWidth: Height of the image (-1 for original width). (integer)
    ; $iHeight: Height of the image (-1 for original height). (integer)
    ; $iLineColor: Argb-color of the borderline of the image. (argb-color)
    ; $iLineWidth: Width of the borderline of the image. (integer)
    ; Return values .: Returns an identifer for this rect. (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_DrawImage($iX, $iY, $sImagePath, $iWidth = -1, $iHeight = -1, $iLineColor = 0xFF000000, $iLineWidth = 2)
    ReDim $__aObjekts[UBound($__aObjekts, 1) + 1][$__El]
    Local $hImage = _GDIPlus_ImageLoadFromFile($sImagePath)
    If $iWidth = -1 Then
    $iWidth = _GDIPlus_ImageGetWidth($hImage)
    EndIf
    If $iHeight = -1 Then
    $iHeight = _GDIPlus_ImageGetHeight($hImage)
    EndIf
    $__aObjekts[UBound($__aObjekts, 1) - 1][0] = "Image"
    $__aObjekts[UBound($__aObjekts, 1) - 1][1] = $iX
    $__aObjekts[UBound($__aObjekts, 1) - 1][2] = $iY
    $__aObjekts[UBound($__aObjekts, 1) - 1][3] = $iWidth
    $__aObjekts[UBound($__aObjekts, 1) - 1][4] = $iHeight
    $__aObjekts[UBound($__aObjekts, 1) - 1][5] = $hImage
    $__aObjekts[UBound($__aObjekts, 1) - 1][6] = $iLineColor
    $__aObjekts[UBound($__aObjekts, 1) - 1][7] = $iLineWidth
    __GDIPlusObjekt_Redraw()
    Return (UBound($__aObjekts, 1) - 1)
    EndFunc ;==>_GDIPlusObjekt_DrawImage

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_ChangeFillColor
    ; Description ...: Changes the fillcolor of an objekt.
    ; Syntax ........: _GDIPlusObjekt_ChangeFillColor($hObjekt, $iNewColor)
    ; Parameters ....: $hObjekt: Handle of the gdi+ -objekt. (handle)
    ; $iNewColor: New argb-fillcolor for this objekt. (argb-color)
    ; Return values .: Succesful: 1 (integer)
    ; Unsuccesful: 0 (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_ChangeFillColor($hObjekt, $iNewColor)
    Switch $__aObjekts[$hObjekt][0]
    Case "Rect"
    $__aObjekts[$hObjekt][6] = $iNewColor
    Case "Triangle"
    $__aObjekts[$hObjekt][8] = $iNewColor
    Case "Ellipse"
    $__aObjekts[$hObjekt][6] = $iNewColor
    Case "Polygon"
    $__aObjekts[$hObjekt][3] = $iNewColor
    Case Else
    Return 0
    EndSwitch
    __GDIPLusObjekt_Redraw()
    Return 1
    EndFunc ;==>_GDIPlusObjekt_ChangeFillColor

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_ChangeLineColor
    ; Description ...: Changes the linecolor of an objekt.
    ; Syntax ........: _GDIPlusObjekt_ChangeLineColor($hObjekt, $iNewColor)
    ; Parameters ....: $hObjekt: Handle of the gdi+ -objekt. (handle)
    ; $iNewColor: New argb-linecolor for this objekt. (argb-color)
    ; Return values .: Succesful: 1 (integer)
    ; Unsuccesful: 0 (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_ChangeLineColor($hObjekt, $iNewColor)
    Switch $__aObjekts[$hObjekt][0]
    Case "Rect"
    $__aObjekts[$hObjekt][5] = $iNewColor
    Case "Triangle"
    $__aObjekts[$hObjekt][7] = $iNewColor
    Case "Ellipse"
    $__aObjekts[$hObjekt][5] = $iNewColor
    Case "String"
    $__aObjekts[$hObjekt][7] = $iNewColor
    Case "Polygon"
    $__aObjekts[$hObjekt][2] = $iNewColor
    Case "Line"
    $__aObjekts[$hObjekt][6] = $iNewColor
    Case "Image"
    $__aObjekts[$hObjekt][6] = $iNewColor
    Case Else
    Return 0
    EndSwitch
    __GDIPLusObjekt_Redraw()
    Return 1
    EndFunc ;==>_GDIPlusObjekt_ChangeLineColor

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_Delete
    ; Description ...: Deletes a gdi+ -objekt.
    ; Syntax ........: _GDIPlusObjekt_Delete($cObjekt)
    ; Parameters ....: $hObjekt: Handle of the gdi+ -objekt. (handle)
    ; Return values .: None.
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_Delete($hObjekt)
    For $__i = 0 To $__El - 1
    $__aObjekts[$hObjekt][$__i] = ""
    Next
    __GDIPlusObjekt_Redraw()
    EndFunc ;==>_GDIPlusObjekt_Delete

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_SetStringText
    ; Description ...: Sets the string of a gdi+ -stringobjekt.
    ; Syntax ........: _GDIPlusObjekt_SetStringText($cObjekt, $sNewString)
    ; Parameters ....: $hObjekt: Handle of the gdi+ -stringobjekt. (handle)
    ; $sNewString: New string for this objekt. (string)
    ; Return values .: Succesful: 1 (integer)
    ; Unsuccesful: 0 (integer)
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: None.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_SetStringText($hObjekt, $sNewString)
    If $__aObjekts[$hObjekt][0] <> "String" Then Return 1
    $__aObjekts[$hObjekt][5] = $sNewString
    __GDIPlusObjekt_Redraw()
    Return 1
    EndFunc ;==>_GDIPlusObjekt_SetStringText

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_GetMsg
    ; Description ...: Returns an array with clicked objekts.
    ; Syntax ........: _GDIPlusObjekt_GetMsg()
    ; Parameters ....: None.
    ; Return values .: Array: [0]= number of clicked elements, [n] = handle to the clicked objekt.
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: To use like GuiGetMsg().
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_GetMsg()
    If _IsPressed(01) And WinActive(_WinAPI_GetWindowText($__GUI)) = $__GUI Then
    Dim $aMsg[1]
    $aMsg[0] = 0
    For $__i = 1 To UBound($__aObjekts, 1) - 1
    Switch $__aObjekts[$__i][0]
    Case "Rect"
    If __GDIPlusObjekt_PointInRect($__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], _WinAPI_GetMousePosX(True, $__GUI), _WinAPI_GetMousePosY(True, $__GUI)) Then
    ReDim $aMsg[UBound($aMsg, 1) + 1]
    $aMsg[UBound($aMsg, 1) - 1] = $__i
    $aMsg[0] += 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "Triangle"
    Local $aTrianglePoints[5][2]
    $aTrianglePoints[0][0] = 3
    $aTrianglePoints[1][0] = $__aObjekts[$__i][1]
    $aTrianglePoints[1][1] = $__aObjekts[$__i][2]
    $aTrianglePoints[2][0] = $__aObjekts[$__i][3]
    $aTrianglePoints[2][1] = $__aObjekts[$__i][4]
    $aTrianglePoints[3][0] = $__aObjekts[$__i][5]
    $aTrianglePoints[3][1] = $__aObjekts[$__i][6]
    $aTrianglePoints[4][0] = $__aObjekts[$__i][1]
    $aTrianglePoints[4][1] = $__aObjekts[$__i][2]
    If __GDIPlusObjekt_PointInPoly(_WinAPI_GetMousePosX(True, $__GUI), _WinAPI_GetMousePosY(True, $__GUI), $aTrianglePoints) Then
    ReDim $aMsg[UBound($aMsg, 1) + 1]
    $aMsg[UBound($aMsg, 1) - 1] = $__i
    $aMsg[0] += 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "Ellipse"
    If __GDIPlusObjekt_PointInEllipse(_WinAPI_GetMousePosX(True, $__GUI), _WinAPI_GetMousePosY(True, $__GUI), $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4]) Then
    ReDim $aMsg[UBound($aMsg, 1) + 1]
    $aMsg[UBound($aMsg, 1) - 1] = $__i
    $aMsg[0] += 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "String"
    If __GDIPlusObjekt_PointInRect($__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], _WinAPI_GetMousePosX(True, $__GUI), _WinAPI_GetMousePosY(True, $__GUI)) Then
    ReDim $aMsg[UBound($aMsg, 1) + 1]
    $aMsg[UBound($aMsg, 1) - 1] = $__i
    $aMsg[0] += 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "Polygon"
    Local $aPolPoints = $__aObjekts[$__i][1]
    If __GDIPlusObjekt_PointInPoly(_WinAPI_GetMousePosX(True, $__GUI), _WinAPI_GetMousePosY(True, $__GUI), $aPolPoints) Then
    ReDim $aMsg[UBound($aMsg, 1) + 1]
    $aMsg[UBound($aMsg, 1) - 1] = $__i
    $aMsg[0] += 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "Image"
    If __GDIPlusObjekt_PointInRect($__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], _WinAPI_GetMousePosX(True, $__GUI), _WinAPI_GetMousePosY(True, $__GUI)) Then
    ReDim $aMsg[UBound($aMsg, 1) + 1]
    $aMsg[UBound($aMsg, 1) - 1] = $__i
    $aMsg[0] += 1
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndSwitch
    Next
    While _IsPressed(01)
    Sleep(10)
    WEnd
    If $aMsg[0] = 0 Then
    Return
    Else
    Return $aMsg
    EndIf
    EndIf
    EndFunc ;==>_GDIPlusObjekt_GetMsg

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ============================================================================================================================
    ; Name ..........: _GDIPlusObjekt_Shutdown
    ; Description ...: Shuts down the _GDIPlusObjekt.au3 functions and the GDI+ engine.
    ; Syntax ........: _GDIPlusObjekt_Shutdown()
    ; Parameters ....: None.
    ; Return values .: None.
    ; Author ........: stayawayknight ([email='stayawayknight@autoit.de'][/email])
    ; Remarks .......: Shuts down the GDI+.au3 too.
    ; =======================================================================================================================================
    Func _GDIPlusObjekt_Shutdown()
    _GDIPlus_BitmapDispose($__hBitmap)
    _GDIPlus_ImageDispose($__hBackbuffer)
    _GDIPlus_GraphicsDispose($__hGraphics)
    Return _GDIPlus_Shutdown()
    EndFunc ;==>_GDIPlusObjekt_Shutdown

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __GDIPlusObjekt_Redraw()
    If $__bBuffer = False Then
    Local $hContext = $__hGraphics
    _GDIPlus_GraphicsClear($__hGraphics, $__iBkColor)
    Else
    _GDIPlus_GraphicsClear($__hBackbuffer, $__iBkColor)
    Local $hContext = $__hBackbuffer
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    For $__i = 1 To UBound($__aObjekts, 1) - 1
    Switch $__aObjekts[$__i][0]
    Case "Rect"
    If $__aObjekts[$__i][6] = Not False Then
    Local $cBrush = _GDIPlus_BrushCreateSolid($__aObjekts[$__i][6])
    _GDIPlus_GraphicsFillRect($hContext, $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], $cBrush)
    _GDIPlus_BrushDispose($cBrush)
    EndIf
    If $__aObjekts[$__i][5] = Not False Then
    Local $cPen = _GDIPlus_PenCreate($__aObjekts[$__i][5], $__aObjekts[$__i][7])
    _GDIPlus_GraphicsDrawRect($hContext, $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], $cPen)
    _GDIPlus_PenDispose($cPen)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "Triangle"
    Local $aTriPoints[4][2]
    $aTriPoints[0][0] = 3
    $aTriPoints[1][0] = $__aObjekts[$__i][1]
    $aTriPoints[1][1] = $__aObjekts[$__i][2]
    $aTriPoints[2][0] = $__aObjekts[$__i][3]
    $aTriPoints[2][1] = $__aObjekts[$__i][4]
    $aTriPoints[3][0] = $__aObjekts[$__i][5]
    $aTriPoints[3][1] = $__aObjekts[$__i][6]
    If $__aObjekts[$__i][8] = Not False Then
    Local $cBrush = _GDIPlus_BrushCreateSolid($__aObjekts[$__i][8])
    _GDIPlus_GraphicsFillPolygon($hContext, $aTriPoints, $cBrush)
    _GDIPlus_BrushDispose($cBrush)
    EndIf
    If $__aObjekts[$__i][7] = Not False Then
    Local $cPen = _GDIPlus_PenCreate($__aObjekts[$__i][7], $__aObjekts[$__i][9])
    _GDIPlus_GraphicsDrawPolygon($hContext, $aTriPoints, $cPen)
    _GDIPlus_PenDispose($cPen)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "Ellipse"
    If $__aObjekts[$__i][6] = Not False Then
    Local $cBrush = _GDIPlus_BrushCreateSolid($__aObjekts[$__i][6])
    _GDIPlus_GraphicsFillEllipse($hContext, $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], $cBrush)
    _GDIPlus_BrushDispose($cBrush)
    EndIf
    If $__aObjekts[$__i][5] = Not False Then
    Local $cPen = _GDIPlus_PenCreate($__aObjekts[$__i][5], $__aObjekts[$__i][7])
    _GDIPlus_GraphicsDrawEllipse($hContext, $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], $cPen)
    _GDIPlus_PenDispose($cPen)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "String"
    __GDIPlusObjekt_GraphicsDrawStringColor($hContext, $__aObjekts[$__i][5], $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][7], $__aObjekts[$__i][6], $__aObjekts[$__i][8], $__aObjekts[$__i][9])

    [/autoit] [autoit][/autoit] [autoit]

    Case "Polygon"
    Local $aPolPoints = $__aObjekts[$__i][1]

    [/autoit] [autoit][/autoit] [autoit]

    If $__aObjekts[$__i][3] = Not False Then
    Local $cBrush = _GDIPlus_BrushCreateSolid($__aObjekts[$__i][3])
    _GDIPlus_GraphicsFillPolygon($hContext, $aPolPoints, $cBrush)
    _GDIPlus_BrushDispose($cBrush)
    EndIf
    If $__aObjekts[$__i][2] = Not False Then
    Local $cPen = _GDIPlus_PenCreate($__aObjekts[$__i][2], $__aObjekts[$__i][4])
    _GDIPlus_GraphicsDrawPolygon($hContext, $aPolPoints, $cPen)
    _GDIPlus_PenDispose($cPen)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Case "Line"
    Local $cPen = _GDIPlus_PenCreate($__aObjekts[$__i][5], $__aObjekts[$__i][6])
    _GDIPlus_GraphicsDrawLine($hContext, $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], $cPen)
    _GDIPlus_PenDispose($cPen)

    [/autoit] [autoit][/autoit] [autoit]

    Case "Image"

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlus_GraphicsDrawImageRect($hContext, $__aObjekts[$__i][5], $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4])
    If $__aObjekts[$__i][5] = Not False Then
    Local $cPen = _GDIPlus_PenCreate($__aObjekts[$__i][6], $__aObjekts[$__i][7])
    _GDIPlus_GraphicsDrawRect($hContext, $__aObjekts[$__i][1], $__aObjekts[$__i][2], $__aObjekts[$__i][3], $__aObjekts[$__i][4], $cPen)
    _GDIPlus_PenDispose($cPen)
    EndIf
    EndSwitch
    Next
    If $__bBuffer = True Then _GDIPlus_GraphicsDrawImageRect($__hGraphics, $__hBitmap, 0, 0, _WinAPI_GetClientWidth($__GUI), _WinAPI_GetClientHeight($__GUI))
    EndFunc ;==>__GDIPlusObjekt_Redraw

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __GDIPlusObjekt_PointInRect($iX1, $iY1, $iWidth, $iHeight, $iX2, $iY2)
    If $iX2 >= $iX1 And $iX2 <= $iX1 + $iWidth And $iY2 >= $iY1 And $iY2 <= $iY1 + $iHeight Then
    Return True
    Else
    Return False
    EndIf
    EndFunc ;==>__GDIPlusObjekt_PointInRect

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __GDIPlusObjekt_PointInPoly($x, $y, $aPoints)
    Local $bEvenNum = False, $xOnLine, $yMin, $yMax
    For $__i = 1 To UBound($aPoints, 1) - 2
    $yMin = _Iif($aPoints[$__i + 1][1] < $aPoints[$__i][1], $aPoints[$__i + 1][1], $aPoints[$__i][1])
    $yMax = _Iif($aPoints[$__i + 1][1] > $aPoints[$__i][1], $aPoints[$__i + 1][1], $aPoints[$__i][1])
    $xOnLine = -($y * $aPoints[$__i + 1][0] - $y * $aPoints[$__i][0] - $aPoints[$__i][1] * $aPoints[$__i + 1][0] + _
    $aPoints[$__i][0] * $aPoints[$__i + 1][1]) / (-$aPoints[$__i + 1][1] + $aPoints[$__i][1])
    If ($x < $xOnLine) And ($y > $yMin) And ($y <= $yMax) Then $bEvenNum = Not $bEvenNum
    Next
    Return $bEvenNum
    EndFunc ;==>__GDIPlusObjekt_PointInPoly

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __GDIPlusObjekt_PointInEllipse($xPt, $yPt, $xTL, $yTL, $w, $h)
    Local $bInside = False, $a = $w / 2, $b = $h / 2
    Local $c1X, $c2X, $dist, $xc = $xTL + $a, $yc = $yTL + $b
    $c1X = $xc - ($a ^ 2 - $b ^ 2) ^ 0.5
    $c2X = $xc + ($a ^ 2 - $b ^ 2) ^ 0.5
    $dist = (($xPt - $c1X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5 + (($xPt - $c2X) ^ 2 + ($yPt - $yc) ^ 2) ^ 0.5
    If $dist <= $w Then $bInside = Not $bInside
    Return $bInside
    EndFunc ;==>__GDIPlusObjekt_PointInEllipse

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func __GDIPlusObjekt_GraphicsDrawStringColor($hGraphics, $sString, $nX, $nY, $iColor = 0xFF000000, $sFont = "Arial", $nSize = 10, $iFormat = 0)
    Local $hBrush = _GDIPlus_BrushCreateSolid($iColor)
    Local $hFormat = _GDIPlus_StringFormatCreate($iFormat)
    Local $hFamily = _GDIPlus_FontFamilyCreate($sFont)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $nSize)
    Local $tLayout = _GDIPlus_RectFCreate($nX, $nY, 0, 0)
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)
    Local $aResult = _GDIPlus_GraphicsDrawStringEx($hGraphics, $sString, $hFont, $aInfo[0], $hFormat, $hBrush)
    Local $iError = @error
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    Return SetError($iError, 0, $aResult)
    EndFunc ;==>__GDIPlusObjekt_GraphicsDrawStringColor

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Function by Bugfix ([email='bufgix@autoit.de'][/email]), modified by stayawayknight.
    Func __GDIPlusObjektGetFontSize($sThing, $sText, $sType, $iFontSize)
    If $sText = '' Then Return
    _GDIPlus_Startup()
    Local $hFormat = _GDIPlus_StringFormatCreate(0)
    Local $hFamily = _GDIPlus_FontFamilyCreate($sType)
    Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize)
    Local $tLayout = _GDIPlus_RectFCreate(15, 171, 0, 0)
    Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND("Desktop")
    Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sText, $hFont, $tLayout, $hFormat)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
    Local $iWidth = Ceiling(DllStructGetData($aInfo[0], "Width"))
    Local $iHeight = Ceiling(DllStructGetData($aInfo[0], "Height"))
    If $sThing = "width" Then
    Return $iWidth
    ElseIf $sThing = "height" Then
    Return $iHeight
    EndIf
    EndFunc ;==>__GDIPlusObjektGetFontSize

    [/autoit]


    Beispiel

    Beispiel
    [autoit]


    #include "GDIPlusObjekt.au3"
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Color.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Opt("GuiOnEventMode", 1) ;Sets the on-event mode. The on-event is not needed to use the GDIPlusObjekt.au3
    OnAutoItExitRegister("ende") ;Registers the function 'ende' as exitfunction.

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("Test", 600, 450, 200, 150) ;Creates a gui.
    GUISetBkColor(0xFFFFFF, $hGui) ;Sets the backgroundcolor of the gui.
    GUISetOnEvent($GUI_EVENT_CLOSE, "ende") ;Set the function 'ende' as an event for the messageid $GUI_EVENT_CLOSE.
    GUISetState(@SW_SHOW)

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlusObjekt_Startup() ;Starts the GDI+ engine.
    _GDIPlusObjekt_GraphicsCreateFromHWnd($hGui, 0xFFFFFFFF, True) ;Creates a Graphics Objekt with the backgroundcolor white and uses a backbuffer to draw.
    $hRect1 = _GDIPlusObjekt_DrawRect(100, 100, 200, 200, 0xFFFFFF00, 0xFFFF5000, 8) ;Draws a rect.
    $hString1 = _GDIPlusObjekt_DrawString(10, 400, "Click on the rect!", 0xFF000000, 15) ;Draws a string.

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1 ;Starts a loop
    $msg = _GDIPlusObjekt_GetMsg() ;Returns an array with GDI+ -objects which are clicked.
    If IsArray($msg) Then ;Checks if return value is an array.
    If $msg[1] = $hRect1 Then ;If the return value is the handle of the rect then exit the while-loop.
    ExitLoop
    EndIf
    EndIf
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlusObjekt_Delete($hRect1) ;Deletes the rect from the gui.
    _GDIPlusObjekt_Delete($hString1) ;Deletes the string from the gui.
    Sleep(1000)
    $hRect1 = _GDIPlusObjekt_DrawRect(0, 0, 200, 200, 0xFFFFFF00, 0xFFFF5000, 8);Draws a rect.
    $hRect2 = _GDIPlusObjekt_DrawRect(150, 150, 200, 200, 0xFFFF0000, 0xFFFF50FF, 8) ;Draws a rect.
    $hString1 = _GDIPlusObjekt_DrawString(10, 400, "Click on the area of the gui, where the rects cover themselves.!", 0xFFFF50FF, 15) ;Draws a string.

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = _GDIPlusObjekt_GetMsg()
    If IsArray($msg) And (UBound($msg) - 1) > 1 Then
    If $msg[1] = $hRect1 And $msg[2] = $hRect2 Then
    ExitLoop
    EndIf
    EndIf
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlusObjekt_Delete($hRect1)
    _GDIPlusObjekt_Delete($hRect2)
    _GDIPlusObjekt_Delete($hString1)
    Sleep(1000)
    $hEllipse1 = _GDIPlusObjekt_DrawEllipse(20, 20, 200, 200, 0xFF000000, 0xFF00FF50)
    $hString1 = _GDIPlusObjekt_DrawString(10, 400, "Click on the ellipse!", 0xFF00FF50, 15)
    Sleep(100)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = _GDIPlusObjekt_GetMsg()
    If IsArray($msg) Then
    If $msg[1] = $hEllipse1 Then
    ExitLoop
    EndIf
    EndIf
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlusObjekt_Delete($hEllipse1)
    _GDIPlusObjekt_Delete($hString1)
    Sleep(1000)
    $hTriangle = _GDIPlusObjekt_DrawTriangle(0, 0, 250, 250, 0, 250, 0xFF000000, 0xFF00FF00)
    $hString1 = _GDIPlusObjekt_DrawString(10, 400, "Click on the triangle!", 0xFF00FF50, 15)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = _GDIPlusObjekt_GetMsg()
    If IsArray($msg) Then
    If $msg[1] = $hTriangle Then
    ExitLoop
    EndIf
    EndIf
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlusObjekt_Delete($hTriangle)
    _GDIPlusObjekt_Delete($hString1)
    Sleep(1000)
    $hString1 = _GDIPlusObjekt_DrawString(100, 200, "Click on this string!", 0xFF00FF50, 30)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = _GDIPlusObjekt_GetMsg()
    If IsArray($msg) Then
    If $msg[1] = $hString1 Then
    ExitLoop
    EndIf
    EndIf
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlusObjekt_Delete($hString1)
    Sleep(1000)

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aPolPoints[6][2]
    $aPolPoints[0][0] = 4
    $aPolPoints[1][0] = 10
    $aPolPoints[1][1] = 10

    [/autoit] [autoit][/autoit] [autoit]

    $aPolPoints[2][0] = 500
    $aPolPoints[2][1] = 10

    [/autoit] [autoit][/autoit] [autoit]

    $aPolPoints[3][0] = 250
    $aPolPoints[3][1] = 60

    [/autoit] [autoit][/autoit] [autoit]

    $aPolPoints[4][0] = 300
    $aPolPoints[4][1] = 100

    [/autoit] [autoit][/autoit] [autoit]

    $aPolPoints[5][0] = 10
    $aPolPoints[5][1] = 10

    [/autoit] [autoit][/autoit] [autoit]

    $hPolygon = _GDIPlusObjekt_DrawPolygon($aPolPoints)
    $hString1 = _GDIPlusObjekt_DrawString(10, 400, "Click on the polygon!", 0xFF00FF50, 15)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = _GDIPlusObjekt_GetMsg()
    If IsArray($msg) Then
    If $msg[1] = $hPolygon Then
    ExitLoop
    EndIf
    EndIf
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    _GDIPlusObjekt_Delete($hPolygon)
    _GDIPlusObjekt_Delete($hString1)
    Sleep(1000)
    $hImage = _GDIPlusObjekt_DrawImage(0, 0, @ScriptDir & "\pic\pic.jpg", -1, -1, 0xFFFF0000, 5)
    $hString1 = _GDIPlusObjekt_DrawString(10, 400, "Click on the Image! 0 times clicked.", 0xFFFF0000, 15)

    [/autoit] [autoit][/autoit] [autoit]

    Dim $aColor[3]
    $iClicked = 0

    [/autoit] [autoit][/autoit] [autoit]

    Do
    $msg = _GDIPlusObjekt_GetMsg()
    If IsArray($msg) Then
    If $msg[1] = $hImage Then
    $aColor[0] = Random(0, 255, 1)
    $aColor[1] = Random(0, 255, 1)
    $aColor[2] = Random(0, 255, 1)
    $iClicked += 1
    _GDIPlusObjekt_ChangeLineColor($hImage, 0xFF & _ColorSetRGB($aColor))
    _GDIPlusObjekt_SetStringText($hString1, "Click on the Image! " & $iClicked & " times clicked.")
    EndIf
    EndIf
    Sleep(10)
    Until $iClicked >= 5

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func ende()
    _GDIPlusObjekt_Shutdown()
    Exit
    EndFunc ;==>ende

    [/autoit]


    Versionen
    - Aktuell Version 1.0 + Beispiel (siehe Anhang)


    Dank
    - An Bugfix, für die Funktion aus dem Textmeter
    - An Xenobiologist, i2c, progandy, Andy, UEZ, AspirinJunkie, misterspeed und eukalyptus für die Hilfe in diesem Thread: Klick mich

    Bin für jeden gefundenen Bug, jeden Verbesserungsvorschlag (auch mein Englisch betreffend :S ) und jede Kritik dankbar!
    Danke euch im Vorraus & viele Grüße,
    stayawayknight

  • Moin

    Ist doch ne ganz passable Angelegenheit.
    Bringt einem GDI Fanatiker zwar nicht viel (außer, dass man die ganzen coolen KollisionsFormeln auf einen Blick hat :P), aber für Anfänger sollte das was gutes sein.

    Spoiler anzeigen
    [autoit]

    Func _GDIPlusObjekt_SetStringText($hObjekt, $sNewString)
    If $__aObjekts[$hObjekt][0] <> "String" Then Return 1
    $__aObjekts[$hObjekt][5] = $sNewString
    __GDIPlusObjekt_Redraw()
    Return 1
    EndFunc ;==>_GDIPlusObjekt_SetStringText

    [/autoit]


    Da muss If $__aObjekts[$hObjekt][0] <> "String" Then Return 0 stehen glaube ich...

    [autoit]

    Func _Kollision_Viereck_Punkt($x1, $y1, $x2, $y2, $b2, $h2) ;Selbsterklärend
    Return ($x1 > $x2 And $y1 > $y2 And $x1 < $x2 + $b2 And $y1 < $y2 + $h2)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    ;ist schneller als:
    Func __GDIPlusObjekt_PointInRect($iX1, $iY1, $iWidth, $iHeight, $iX2, $iY2)
    If $iX2 >= $iX1 And $iX2 <= $iX1 + $iWidth And $iY2 >= $iY1 And $iY2 <= $iY1 + $iHeight Then
    Return True
    Else
    Return False
    EndIf
    EndFunc ;==>__GDIPlusObjekt_PointInRect

    [/autoit]

    Geschwindigkeitsmäßig geht es eigentlich.
    Man kann noch versuchen Stringvergleiche gegen Intvergleiche auszutauschen (indem du z.B. $___Ellipse = 5 (z.B.) nutzt um die Ellipse zu definieren statt "Ellipse").
    Sonst keine Einwände :P

  • Hi,

    ich finde das auch klasse!

    Habe direkt angefangen mein Script darauf umzubauen. Aber ich hab da gleich mal eine Frage.

    Am anfang erstellt man ja das...

    [autoit]

    _GDIPlusObjekt_GraphicsCreateFromHWnd

    [/autoit]


    Ist ja soweit auch gut. Aber kann ich auch irgendwie die Position angeben? Weil so übermalt er mir meine grpboxen, buttons, inputboxen etc.
    Ich hätte das Graphics objekt gerne nur auf der rechten Seite, innerhalb einer grpbox.

    Edit: Ok habs gefunden! In der "GDIPlusObjekt.au3" in

    [autoit]

    __GDIPlusObjekt_Redraw()

    [/autoit]

    kann man es ganz unten ändern.
    Wie wäre es mit einer Options Func. Da könnte man dann sowas am anfang des Scriptes mit angeben. Fürs erste werde ich mir selbst sowas reinschreiben.

    Edit2: Ok ich sehs ein is ne schlechte Idee, weil dann die Berechnungen der Positionen nicht mehr passen. Mh wie könnte ichs dann machen?

    Danke
    Gruß Daniel

    PS: Unbedingt weiter entwickeln!!!

    2 Mal editiert, zuletzt von danielsan85 (11. Februar 2011 um 17:35)

  • Hallo,
    danke für euer nettes Feedback!
    @Marsi: Danke für den Hinweis, werde deine Vorschläge in der nächsten Version umsetzen!
    Blume: Hab ich mir auch schon überlegt, mal sehen...
    @danielsan85: Danke dir, werde so etwas einbauen!

    Einmal editiert, zuletzt von stayawayknight (11. Februar 2011 um 19:39)