Liste
Enoncé

Visual Basic - Solution 2 ( Editeur d'icône simplifié )

 

Interface graphique :

ex2im2i.gif (11228 octets)

Code de la feuille Form1 :

Dim grille (1 To 16, 1 To 16) As Integer
Dim pal (1 To 16) As Integer
Dim couleur As Integer

Private Sub Bouton_Effacer_Click()
     Form_Activate
End Sub

Private Sub Form_Activate()
     Dim i As Integer, j As Integer
     DoEvents

     '1) Echelle de la grille
     Picture1.Scale (0, 16)-(16, 0)
     '2) Initialisation de la grille et affichage initial
     Picture1.FillStyle = 0
     couleur = 15 'Blanc
     Picture1.FillColor = QBColor(couleur) 'On pourrait aussi utiliser VBWhite avec VB5
     For i = 1 To 16 'pour X
          For j = 1 To 16 'pour Y
               grille(i, j) = couleur
               Picture1.Line (i - 1, j - 1)-(i, j), , B
          Next j
     Next i
     'Définition de l'échelle de la palette
     Picture2.Scale (0, 16)-(1, 0)
     Picture2.FillStyle = 0
     For i = 1 To 16
          Picture2.FillColor = QBColor(i - 1)
          Picture2.Line (0, i - 1)-(1, i), , B
     Next i
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     grille(Int(X), Int(Y)) = couleur
     Picture1.Line (Int(X), Int(Y))-(Int(X) + 1, Int(Y) + 1), , B
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
     If Button <> 0 Then Picture1_MouseDown Button, Shift, X, Y
End Sub

Private Sub Picture2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
     couleur = Int(Y)
     Picture1.FillColor = QBColor(couleur)
End Sub

    ( retour à l'énoncé )