Funktionreferenz


_GDIPlus_GraphicsCreateFromHDC

Beschreibung anzeigen in

Erstellt ein Grafik-Objekt aus einem Gerätekontext

#include <GDIPlus.au3>
_GDIPlus_GraphicsCreateFromHDC ( $hDC )

Parameter

$hDC Handle zu einem Gerätekontext

Rückgabewert

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

Bemerkungen

Wenn man mit dem Grafik-Objekt fertig ist, ist _GDIPlus_GraphicsDispose() aufzurufen um die Ressourcen wieder freizugeben

Verwandte Funktionen

_GDIPlus_GraphicsDispose

Siehe auch

Suche nach GdipCreateFromHDC in der MSDN Bibliothek.

Beispiel

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

Example()

Func Example()
    Local $hGui, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $hDC

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

    ; Zeichnet einen String
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC)
    $hBrush = _GDIPlus_BrushCreateSolid(0x7F00007F)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
    $tLayout = _GDIPlus_RectFCreate(140, 110, 100, 20)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, "Hallo Welt", $hFont, $tLayout, $hFormat, $hBrush)

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

    ; Ressourcen freigeben
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _WinAPI_ReleaseDC($hGui, $hDC)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example