Bonjour,

j'essaie de comprendre comment fonctionnent les tests d'atteinte.
j'ai donc créé ce petit programme (en fait repris de chez msdn):

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
Imports System.Drawing.Drawing2D
Imports System.Drawing
 
 
Public Class Form1
 
    Dim g As Graphics
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
        g = Me.CreateGraphics
 
        'g.SetClip(New Region(New Rectangle(0, 0, 100, 100)), CombineMode.Replace)
 
        ' Create an array of points for the curve in the second figure.
        Dim points As Point() = { _
           New Point(40, 60), _
           New Point(50, 70), _
           New Point(30, 90)}
 
        Dim path As New GraphicsPath()
 
        path.StartFigure() ' Start the first figure.
        path.AddArc(175, 50, 50, 50, 0, -180)
        path.AddLine(100, 50, 250, 20)
        path.CloseFigure()
 
        ' First figure is not closed.
 
        path.StartFigure() ' Start the second figure.
        path.AddLine(50, 20, 5, 90)
        path.AddCurve(points, 3)
        path.AddLine(50, 150, 150, 180)
        path.CloseFigure() ' Second figure is closed.
        g.FillPath(New SolidBrush(Color.FromArgb(255, 255, 0, 0)), path)
 
        g.SetClip(New Region(New Rectangle(0, 0, 100, 100)), CombineMode.Replace)
 
 
    End Sub
 
 
    Private Sub Form1_MouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseClick
 
        If Region.IsVisible(New Point(e.Location), g) Then
            MessageBox.Show("OK")
        Else
            MessageBox.Show("pas OK")
        End If
 
    End Sub
End Class
et dans la ligne correspondant à "if region.isvisible...", j'ai un message d'erreur :"la référence d'objet n'est pas définie à une instance d'objet...".

savez-vous d'où vient l'erreur?

cordialement,

lolveley.