UDF > WinAPIEx > GDI > Rectangle >


_WinAPI_IntersectRect

Détermine l'intersection de deux rectangles

#include <WinAPIGdi.au3>
_WinAPI_IntersectRect ( $tRECT1, $tRECT2 )

Paramètres

$tRECT1 Structure $tagRECT qui contient le premier rectangle source.
$tRECT2 Structure $tagRECT qui contient le second rectangle source.

Valeur de retour

Succès: Retourne la structure $tagRECT qui contient l'intersection des rectangles $tRECT1 et $tRECT2.
Échec: Définit @error <> 0.

Remarque

Si les rectangles source n'ont pas d'intersection, un rectangle vide (pour lequel toutes les coordonnées sont mises à zéro) est placé dans le rectangle de destination.

Voir aussi

Consultez IntersectRect dans la librairie MSDN.

Exemple

#include <WinAPIGdi.au3>

Global $tRect1, $tRect2, $tRect3

$tRect1 = DllStructCreate($tagRECT)
DllStructSetData($tRect1, 10, 10)
DllStructSetData($tRect1, 20, 10)
DllStructSetData($tRect1, 30, 40)
DllStructSetData($tRect1, 40, 50)

$tRect2 = DllStructCreate($tagRECT)
DllStructSetData($tRect2, 10, 30)
DllStructSetData($tRect2, 20, 20)
DllStructSetData($tRect2, 30, 50)
DllStructSetData($tRect2, 40, 60)

; Un appel direct à l'API donnerait:
;$tRect3 =DllStructCreate($tagRECT)
;DllCall("user32.dll", "BOOL", "IntersectRect", "PTR", DllStructGetPtr($tRect3), "PTR", DllStructGetPtr($tRect1), "PTR", DllStructGetPtr($tRect2))

; Un appel à la fonction AutoIt s'écrit simplement:
$tRect3 = _WinAPI_IntersectRect($tRect1, $tRect2)

; Résultat
MsgBox(0, "IntersectRect", "[" & DllStructGetData($tRect3, 1) & ',' & DllStructGetData($tRect3, 2) & ',' & DllStructGetData($tRect3, 3) & ',' & DllStructGetData($tRect3, 4) & ']')

; Libère la mémoire
$tRect1 = 0
$tRect2 = 0
$tRect3 = 0