_GDIPlus_GraphicsMeasureString
Measures the size of a string
#include <GDIPlus.au3>
_GDIPlus_GraphicsMeasureString($hGraphics, $sString, $hFont, $tLayout, $hFormat)
Параметры
$hGraphics | Дескриптор графического объекта |
$sString |
String to be drawn |
$hFont |
Handle to the font to use to draw the string |
$tLayout |
$tagGDIPRECTF structure that bounds the string |
$hFormat |
Handle to the string format to draw the string |
Возвращаемое значение
Успех: | Array with the following format |
[0] - $tagGDIPRECTF structure that receives the rectangle that bounds the string | |
[1] - The number of characters that actually fit into the layout rectangle | |
[2] - The number of lines that fit into the layout rectangle | |
Ошибка: | Возвращает 0 |
См. также
$tagGDIPRECTFСм. также
Искать GdipMeasureString в библиотеке MSDNПример
#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
_Main()
Func _Main()
Local $hGUI, $hGraphic, $hBrush, $hFormat, $hFamily, $hFont, $tLayout, $aInfo
Local $sString = "Hello world"
; Создаёт GUI
$hGUI = GUICreate("GDI+", 400, 300)
GUISetState()
; Рисует строку
_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)
; Цикл выполняется, пока окно не будет закрыто
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; Очищает ресурсы
_GDIPlus_FontDispose ($hFont)
_GDIPlus_FontFamilyDispose ($hFamily)
_GDIPlus_StringFormatDispose ($hFormat)
_GDIPlus_BrushDispose ($hBrush)
_GDIPlus_GraphicsDispose ($hGraphic)
_GDIPlus_Shutdown ()
EndFunc ;==>_Main