Misst die Größe eines Strings
#include <GDIPlus.au3>
_GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)
| $hGraphics | Handle zu einem Grafik-Objekt |
| $sString | Zu zeichnende Strings |
| $hFont | Handle zur verwendeten Schrift |
| $tLayout | $tagGDIPRECTF-Struktur, welche der String begrenzt |
| $hFormat | Handle zum verwendeten Stringformat |
| Erfolg: | Array mit dem folgenden Format |
| [0] - $tagGDIPRECTF-Struktur, die das Rechteck enthält, welches der String begrenzt | |
| [1] - Die Anzahl an Zeichen, die in das $tLayout-Rechteck passen | |
| [2] - Die Anzahl an Zeilen, die in das $tLayout-Rechteck passen | |
| Fehler: | 0 |
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
_Main()
Func _Main()
Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $aInfo
Local $sString = "Hallo Welt"
; Erstellt eine GUI
$hGUI = GUICreate("GDI+", 400, 300)
GUISetState()
; Zeichnet einen String
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF00007F)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 12, 2)
$tLayout = _GDIPlus_RectFCreate(140, 110, 0, 0)
$aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $sString, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $aInfo[0], $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)
_GDIPlus_Shutdown()
EndFunc ;==>_Main