Create a String Format object
#include <GDIPlus.au3>
_GDIPlus_StringFormatCreate ( [$iFormat = 0 [, $iLangID = 0]] )
$iFormat | [optional] Format flags. Can be one or more of the following: 0x0001 - Specifies that reading order is right to left 0x0002 - Specifies that individual lines of text are drawn vertically on the display device 0x0004 - Specifies that parts of characters are allowed to overhang the string's layout rectangle 0x0020 - Specifies that Unicode layout control characters are displayed with a representative character 0x0400 - Specifies that an alternate font is used for characters that are not supported in the requested font 0x0800 - Specifies that the space at the end of each line is included in a string measurement 0x1000 - Specifies that the wrapping of text to the next line is disabled 0x2000 - Specifies that only entire lines are laid out in the layout rectangle 0x4000 - Specifies that characters overhanging the layout rectangle and text extending outside the layout rectangle are allowed to show |
$iLangID | [optional] The language to use |
Success: | a handle to a string format object. |
Failure: | 0 and sets the @error flag to non-zero, @extended may contain GPSTATUS error code ($GPIP_ERR* see GPIPlusConstants.au3). |
When you are done with the String Format object, call _GDIPlus_StringFormatDispose() to release the resources.
_GDIPlus_StringFormatDispose, _GDIPlus_StringFormatSetAlign
Search GdipCreateStringFormat in MSDN Library.
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
Example()
Func Example()
Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout
; Create GUI
$hGUI = GUICreate("GDI+", 400, 300)
GUISetState(@SW_SHOW)
; Draw a 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, 100, 20)
_GDIPlus_GraphicsDrawStringEx($hGraphic, "Hello world", $hFont, $tLayout, $hFormat, $hBrush)
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Clean up resources
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_BrushDispose($hBrush)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
EndFunc ;==>Example