Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionOption Explicit Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long Private Const RGN_AND = 1 Private Const NULLREGION = 1 Private Sub Form_Load() Dim RGN1 As Long, RGN2 As Long '# Cas d'intersection entre les deux regions RGN1 = CreateRectRgn(0, 0, 100, 100) RGN2 = CreateRectRgn(50, 50, 150, 150) MsgBox "Cas 1 : " & RgnInRgn(RGN1, RGN2) '# Cas de non intersection entre les deux regions RGN1 = CreateRectRgn(0, 0, 100, 100) RGN2 = CreateRectRgn(150, 150, 250, 250) MsgBox "Cas 2 : " & RgnInRgn(RGN1, RGN2) End End Sub Public Function RgnInRgn(ByVal RGN1 As Long, ByVal RGN2 As Long) As Boolean '# RGNOUT doit pointer sur une region valide !! Dim RGNOUT As Long: RGNOUT = CreateRectRgn(0, 0, 0, 0) '# CombineRGN renvoie NULLREGION si la region est vide '# Dans le cas présent, on tente d'effectuer une intersection des deux regions. (RGN_AND) RgnInRgn = NULLREGION <> CombineRgn(RGNOUT, RGN1, RGN2, RGN_AND) End Function
Public Function RgnInRgn(ByVal RGN1 As Long, ByVal RGN2 As Long) As Boolean '# RGNOUT doit pointer sur une region valide !! Dim RGNOUT As Long: RGNOUT = CreateRectRgn(0, 0, 0, 0) '# CombineRGN renvoie NULLREGION si la region est vide '# Dans le cas présent, on tente d'effectuer une intersection des deux regions. (RGN_AND) RgnInRgn = NULLREGION <> CombineRgn(RGNOUT, RGN1, RGN2, RGN_AND) DeleteObject RGNOUT ' Important sinon ca peut planter, j'ai fais des test. End Function