D�finit une s�rie de plages de caract�res pour un objet StringFormat qui, dans une cha�ne, peuvent �tre mesur�es
#include <GDIPlus.au3>
_GDIPlus_StringFormatSetMeasurableCharacterRanges ( $hStringFormat, $aRanges )
$hStringFormat | Handle de l'objet StringFormat |
$aRanges | Tableau de plages de caract�res : [0][0] - Nombre de plages de caract�res [1][0] - Plage 1, position (base 0) du premier caract�re de la plage [1][1] - Plage 1, nombre de caract�res de la plage [2][0] - Plage 2, position du premier caract�re de la plage 2 [2][1] - Plage 2, nombre de caract�res de la plage 2 [n][0] - Plage n, position du premier caract�re de la plage n [n][1] - Plage n, nombre de caract�res de la plage n |
Succ�s: | Retourne True. |
�chec: | Retourne False et d�finit @error <> 0, @extended contient le code erreur ($GPID_ERR*). |
La fonction permet de d�finir un tableau de plages de caract�re qui repr�sentent les plages mesur�es par un appel � la fonction MeasureCharacterRanges.
_GDIPlus_GraphicsMeasureCharacterRanges, _GDIPlus_StringFormatGetMeasurableCharacterRangeCount
Consultez GdipSetStringFormatMeasurableCharacterRanges dans la Librairie MSDN.
#include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() ; Cr�e GUI Local $hGUI = GUICreate("GDI+", 640, 220) GUISetState(@SW_SHOW) _GDIPlus_Startup() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Cr�e un objet graphique � partir d'un handle fen�tre _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) Local $hPen = _GDIPlus_PenCreate(0xFF006600) Local $hBrush_Region = _GDIPlus_BrushCreateSolid(0x44FF0000) Local $hBrush_Font = _GDIPlus_BrushCreateSolid(0xFFFF0000) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $sString = "Measure Character Ranges" Local $aRanges[4][2] = [[3]] $aRanges[1][0] = 0 ; Mesure le premier caract�re (de base 0) $aRanges[1][1] = 1 ; Un caract�re � mesurer $aRanges[2][0] = 4 ; 5-i�me caract�re $aRanges[2][1] = 5 ; Mesure 5 caract�res $aRanges[3][0] = 14 ; Le 15-i�me caract�re $aRanges[3][1] = 7 ; Mesure 7 caract�res _GDIPlus_StringFormatSetMeasurableCharacterRanges($hFormat, $aRanges) ; D�finir les plages ; Mesure la taille des caract�res d'une fonte de 14 Local $hFont = _GDIPlus_FontCreate($hFamily, 14, 0) Local $tLayout = _GDIPlus_RectFCreate(10, 10, 200, 200) _GDIPlus_GraphicsDrawRect($hGraphic, 10, 10, 200, 200, $hPen) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font) Local $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) ; Obtient l'ensemble des r�gions For $i = 1 To $aRegions[0] _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region) _GDIPlus_RegionDispose($aRegions[$i]) Next _GDIPlus_FontDispose($hFont) ; Mesure la taille des caract�res d'une fonte de 28 $hFont = _GDIPlus_FontCreate($hFamily, 28, 0) $tLayout = _GDIPlus_RectFCreate(220, 10, 200, 200) _GDIPlus_GraphicsDrawRect($hGraphic, 220, 10, 200, 200, $hPen) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font) $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) For $i = 1 To $aRegions[0] _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region) _GDIPlus_RegionDispose($aRegions[$i]) Next _GDIPlus_FontDispose($hFont) ; Mesure la taille des caract�res d'une fonte de 56 $hFont = _GDIPlus_FontCreate($hFamily, 56, 0) $tLayout = _GDIPlus_RectFCreate(430, 10, 200, 200) _GDIPlus_GraphicsDrawRect($hGraphic, 430, 10, 200, 200, $hPen) _GDIPlus_GraphicsDrawStringEx($hGraphic, $sString, $hFont, $tLayout, $hFormat, $hBrush_Font) $aRegions = _GDIPlus_GraphicsMeasureCharacterRanges($hGraphic, $sString, $hFont, $tLayout, $hFormat) For $i = 1 To $aRegions[0] _GDIPlus_GraphicsFillRegion($hGraphic, $aRegions[$i], $hBrush_Region) _GDIPlus_RegionDispose($aRegions[$i]) Next _GDIPlus_FontDispose($hFont) Local $iCount = _GDIPlus_StringFormatGetMeasurableCharacterRangeCount($hFormat) MsgBox($MB_SYSTEMMODAL, "", "MeasurableCharacterRangeCount: " & $iCount) ; Boucle jusqu'� ce que l'utilisateur quitte. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Nettoie les ressources _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush_Font) _GDIPlus_BrushDispose($hBrush_Region) _GDIPlus_PenDispose($hPen) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example