1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Option Explicit
'Pour lire la couleur du pixel sous le curseur
Private Declare Function GetPixel Lib "gdi32" _
(ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Dim Couleur As Long
Private Sub Form_Load()
Shape1.FillStyle = 0 'solid
Shape1.Move 60, 60, 315, 315
Shape2.FillStyle = 0 'solid
Shape2.Move Shape1.Left + Shape1.Width + 15, 60, 315, 315
Picture1.ScaleMode = vbPixels
Picture1.Move 60, Shape1.Top + Shape1.Height + 15
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Shape1.FillColor = GetPixel(Picture1.hdc, X, Y)
End Sub
Private Sub Picture1_Click()
Couleur = Shape1.FillColor
Shape2.FillColor = Couleur
End Sub |
Partager