UDF > GDIPlus > Graphics >


_GDIPlus_GraphicsFillRect

Remplit un rectangle

#include <GDIPlus.au3>
_GDIPlus_GraphicsFillRect ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $hBrush = 0] )

Paramètres

$hGraphics Handle de l'objet Graphics
$nX La coordonnée X du coin supérieur gauche du rectangle
$nY La coordonnée Y du coin supérieur gauche du rectangle,
$nWidth La largeur du rectangle
$nHeight La hauteur du rectangle
$hBrush [optionnel] Handle de l'objet Brush (pinceau) qui est utilisé pour remplir le rectangle. Si 0, un pinceau noir sera utilisée.

Valeur de retour

Succès: Retourne True.
Échec: Retourne False et définit @error <> 0, @extended contient le code erreur GPSTATUS ($GPID_ERR*).

Voir aussi

Consultez GdipFillRectangle dans la Librairie MSDN.

Exemples

Exemple 1

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

Example()

Func Example()
    Local $hGUI, $hGraphic

    ; Crée GUI
    $hGUI = GUICreate("GDI+", 400, 300)
    GUISetState(@SW_SHOW)

    ; Remplit un rectangle
    _GDIPlus_Startup()
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
    _GDIPlus_GraphicsFillRect($hGraphic, 10, 10, 100, 100)

    ; Boucle jusqu'à ce que l'utilisateur quitte.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Nettoie les ressources
    _GDIPlus_GraphicsDispose($hGraphic)
    _GDIPlus_Shutdown()
EndFunc   ;==>Example

Exemple 2

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

Example()

Func Example()
    _GDIPlus_Startup() ; Initialise GDI+
    Local Const $iWidth = 600, $iHeight = 600, $iBgColor = 0x303030 ; $iBGColor est au format RRGGBB

    Local $hGUI = GUICreate("GDI+ example", $iWidth, $iHeight) ; Crée une fenêtre de test
    GUISetBkColor($iBgColor, $hGUI) ; Définit la couleur de fond de la GUI
    GUISetState(@SW_SHOW)

    Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGUI) ; Crée un objet Graphics à partir du handle de la fenêtre
    _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ; Définit pour l'objet graphique la qualité de rendu antialiasing
    Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB) ; Format de couleur AARRGGBB (hex)

    _GDIPlus_GraphicsFillRect($hGraphics, 150.5, 50.1, 280.25, 500.75, $hBrush)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Nettoie les ressources GDI+
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc   ;==>Example