Bonjour, j'ai compris que l'exécution d'une application démarre par l'affichage du Form1 (par défaut) donc du déclanchement de l'évènement Form1_Load. Est-ce que l'affichage du Form1 génère un évènement OnPaint qui déclanche lui-même l'évènement Paint ?
Dans le code qui suit je n'ai pas de déclancheur de l'évènement Paint, pourtant il s'exécute ???
Merci de me préciser ce point.
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 Public Class Form1 Private Sub Fenetre_1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.SetDesktopLocation(50, 200) Me.Size = New Size(500, 500) Me.Text = "Fenêtre 1" Fenetre_2.Show() End Sub Private Sub Fenetre_1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim Position As New Point(100, 100) Deplace_Est(Position, e) End Sub Private Sub Deplace_Est(ByRef Position As Point, ByRef e As System.Windows.Forms.PaintEventArgs) Dim Point_Av As New Point Dim Point_Ar As New Point Dim i As Integer 'direction Est For i = 1 To 100 Position.X = Position.X + 1 'image avant Point_Av.X = Position.X Point_Av.Y = Position.Y - 8 e.Graphics.DrawImage(My.Resources.Cellule_Est_Av, Point_Av) 'image arrière Point_Ar.X = Position.X - 16 Point_Ar.Y = Position.Y - 8 e.Graphics.DrawImage(My.Resources.Cellule_Est_Ar, Point_Ar) Pause(30) Next End Sub Private Sub Pause(ByVal Delai As Integer) System.Threading.Thread.Sleep(Delai) End Sub End Class
Partager