Funktionreferenz


_GDIPlus_PenCreate

Beschreibung anzeigen in

Erzeugt ein Zeichenstift Objekt

#include <GDIPlus.au3>
_GDIPlus_PenCreate ( [$iARGB = 0xFF000000 [, $nWidth = 1 [, $iUnit = 2]]] )

Parameter

$iARGB [optional] Alpha, Rot, Grün und Blau-Komponenten der Zeichenstiftfarbe
$nWidth [optional] Die Breite des Zeichenstiftes, gemessen in den Einheiten, die im $iUnit-Parameter festgelegt sind.
$iUnit [optional] Maßeinheit für die Zeichenstiftgröße:
    0 - Welt-Koordinaten, eine nicht-physikalische Einheit
    1 - Darstellungseinheiten
    2 - Eine Einheit ist 1 Pixel
    3 - Eine Einheit ist 1 Punkt oder 1/72 Zoll
    4 - Eine Einheit ist 1 Zoll
    5 - Eine Einheit ist 1/300 Zoll
    6 - Eine Einheit ist 1 Millimeter

Rückgabewert

Erfolg: ein Handle auf das Zeichenstift-Objekt
Fehler: 0 und setzt das @error Flag auf ungleich null. @extended kann den GPSTATUS Fehlercode ($GPID_ERR* siehe GDIPlusConstants.au3) enthalten.

Bemerkungen

Wenn man mit dem Zeichenstift fertig ist, sollte man zur Freigabe der Ressourcen _GDIPlus_PenDispose() aufrufen.

Verwandte Funktionen

_GDIPlus_PenDispose

Siehe auch

Suche nach GdipCreatePen1 in der MSDN Bibliothek.

Beispiel

Beispiel 1

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $hGui, $hGraphic, $hPen

    ; Erstellt eine GUI
    $hGui = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Zeichnet eine Linie
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGui)
    $hPen = _GDIPlus_PenCreate()
    _GDIPlus_GraphicsDrawLine($hGraphic, 10, 150, 390, 150, $hPen)

    ; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslöst.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Ressourcen freigeben
    _GDIPlus_PenDispose($hPen)
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Beispiel 2

#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>

Global $g_hGUI, $g_hGraphics, $g_hBitmap, $g_hGfxCtxt, $g_hPen

Example()

Func Example()
    AutoItSetOption("GUIOnEventMode", 1)

    _GDIPlus_Startup() ;initialize GDI+
    Local $iW = 600, $iH = 600
    Local Const $iBgColor = 0x303030 ;$iBGColor format RRGGBB

    $g_hGUI = GUICreate("GDI+ Example (" & @ScriptName & ")", $iW, $iH) ;create a test GUI
    GUISetBkColor($iBgColor, $g_hGUI) ;set GUI background color
    GUISetState(@SW_SHOW)

    ;create buffered graphics frame set for smoother gfx object movements
    $g_hGraphics = _GDIPlus_GraphicsCreateFromHWND($g_hGUI) ;create a graphics object from a window handle
    $g_hBitmap = _GDIPlus_BitmapCreateFromGraphics($iW, $iH, $g_hGraphics)
    $g_hGfxCtxt = _GDIPlus_ImageGetGraphicsContext($g_hBitmap)
    _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing)
    $g_hPen = _GDIPlus_PenCreate(0xFF8080FF, 2)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

    Local Const $fDeg = ACos(-1) / 180, $iRadius = 300, $iWidth = $iW / 2, $iHeight = $iH / 2
    Local $fAngle = 0

    Do
        _GDIPlus_GraphicsClear($g_hGfxCtxt, 0xFF000000 + $iBgColor) ;clear bitmap for repaint
        _GDIPlus_GraphicsDrawEllipse($g_hGfxCtxt, $iWidth - $iRadius / 2 + $iRadius / 18, $iHeight - $iRadius / 2 + $iRadius / 18, $iRadius - $iRadius / 9, $iRadius - $iRadius / 9, $g_hPen) ;draw ellipse
        _GDIPlus_GraphicsDrawLine($g_hGfxCtxt, $iWidth + Cos($fAngle * $fDeg) * $iRadius, $iHeight + Sin($fAngle * $fDeg) * $iRadius, _ ;draw line
                $iWidth + Cos($fAngle * $fDeg + 180) * $iRadius, $iHeight + Sin($fAngle * $fDeg + 180) * $iRadius, $g_hPen)

        _GDIPlus_GraphicsDrawImageRect($g_hGraphics, $g_hBitmap, 0, 0, $iW, $iH) ;copy drawn bitmap to graphics handle (GUI)
        $fAngle += 0.5
    Until Not Sleep(20) ;sleep 20 ms to avoid high cpu usage
EndFunc   ;==>Example

Func _Exit()
    ;cleanup GDI+ resources
    _GDIPlus_PenDispose($g_hPen)
    _GDIPlus_GraphicsDispose($g_hGfxCtxt)
    _GDIPlus_GraphicsDispose($g_hGraphics)
    _GDIPlus_BitmapDispose($g_hBitmap)
    _GDIPlus_Shutdown()
    GUIDelete($g_hGUI)
    Exit
EndFunc   ;==>_Exit