UDF > GDIPlus > Graphics >


_GDIPlus_GraphicsDrawRect

Dessine un rectangle

#include <GDIPlus.au3>
_GDIPlus_GraphicsDrawRect ( $hGraphics, $nX, $nY, $nWidth, $nHeight [, $hPen = 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
$hPen [optionnel] Handle de l'objet Pen qui est utilis� pour dessiner le rectangle. Si 0, un crayon noir qui trace des traits continus de largeur de 1 sera utilis�

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 GdipDrawRectangle dans la Librairie MSDN.

Exemples

Exemple 1

#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WinAPIHObj.au3>

Example()

Func Example()
    Local $hBitmap1, $hBitmap2, $hImage1, $hImage2, $hGraphics

    ; Initialise la biblioth�que GDI+
    _GDIPlus_Startup()

    ; Capture l'�cran complet
    $hBitmap1 = _ScreenCapture_Capture("")
    $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)

    ; Capture une r�gion d'�cran
    $hBitmap2 = _ScreenCapture_Capture("", 0, 0, 400, 300)
    $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap2)

    ; Dessine une image dans une autre
    $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage1)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 100, 100)

    ; Dessine un cadre autour de l'image ins�r�e
    _GDIPlus_GraphicsDrawRect($hGraphics, 100, 100, 400, 300)

    ; Enregistre l'image r�sultante
    _GDIPlus_ImageSaveToFile($hImage1, @MyDocumentsDir & "\GDIPlus_Image.jpg")

    ; Nettoie les ressources
    _GDIPlus_ImageDispose($hImage1)
    _GDIPlus_ImageDispose($hImage2)
    _WinAPI_DeleteObject($hBitmap1)
    _WinAPI_DeleteObject($hBitmap2)

    ; Arr�te la biblioth�que GDI+
    _GDIPlus_Shutdown()

    ShellExecute(@MyDocumentsDir & "\GDIPlus_Image.jpg")
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 $hPen = _GDIPlus_PenCreate(0xFFFEDCBA, 4) ; Format de couleur AARRGGBB (hex)

    _GDIPlus_GraphicsDrawRect($hGraphics, 150.5, 50.1, 280.25, 500.75, $hPen)

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

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