Sur mon form j'ai une Picture1, un Command1 et 3 labels.
Voici mon code :
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc
As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor
As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc
As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Sub Command1_Click()
i = 0
For X = 0 To 255
For Y = 0 To 255
z = X + Y
SetPixel Me.Picture1.hdc, X, Y, RGB(X, Y, z)
Next Y
Next X
End Sub
Private Sub Form_Load()
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As
Integer, X As Single, Y As Single)
Me.lblX = X
Me.lblY = Y
Me.lblCouleur = GetPixel(Me.Picture1.hdc, X, Y)
End Sub
Quelqu'un peut il me dire pourquoi dans lblCouleur j'ai
toujours -1 ?
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
François Picalausa
"Nicolas" a écrit dans le message de news:002601c3c57a$0dbe6790$
Bonjour,
Sur mon form j'ai une Picture1, un Command1 et 3 labels.
Voici mon code :
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Sub Command1_Click() i = 0 For X = 0 To 255 For Y = 0 To 255 z = X + Y SetPixel Me.Picture1.hdc, X, Y, RGB(X, Y, z) Next Y Next X
End Sub
Private Sub Form_Load()
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.lblX = X Me.lblY = Y Me.lblCouleur = GetPixel(Me.Picture1.hdc, X, Y) End Sub
Quelqu'un peut il me dire pourquoi dans lblCouleur j'ai toujours -1 ?
Bonjour/soir,
Probablement parce que tu te situe en dehors de limites...
Essaye dans Private Sub Form_Load(): Picture1.ScaleMode = 3
Pour éviter qu'il ne travaille en twips.
Une autre solution est d'utiliser Point et/ou Pset à la place de Get et SetPixel.
"Nicolas" <nicolasheurtevin@wanadoo.fr> a écrit dans le message de
news:002601c3c57a$0dbe6790$a101280a@phx.gbl
Bonjour,
Sur mon form j'ai une Picture1, un Command1 et 3 labels.
Voici mon code :
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc
As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor
As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc
As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Sub Command1_Click()
i = 0
For X = 0 To 255
For Y = 0 To 255
z = X + Y
SetPixel Me.Picture1.hdc, X, Y, RGB(X, Y, z)
Next Y
Next X
End Sub
Private Sub Form_Load()
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As
Integer, X As Single, Y As Single)
Me.lblX = X
Me.lblY = Y
Me.lblCouleur = GetPixel(Me.Picture1.hdc, X, Y)
End Sub
Quelqu'un peut il me dire pourquoi dans lblCouleur j'ai
toujours -1 ?
Bonjour/soir,
Probablement parce que tu te situe en dehors de limites...
Essaye dans Private Sub Form_Load():
Picture1.ScaleMode = 3
Pour éviter qu'il ne travaille en twips.
Une autre solution est d'utiliser Point et/ou Pset à la place de Get et
SetPixel.
"Nicolas" a écrit dans le message de news:002601c3c57a$0dbe6790$
Bonjour,
Sur mon form j'ai une Picture1, un Command1 et 3 labels.
Voici mon code :
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Sub Command1_Click() i = 0 For X = 0 To 255 For Y = 0 To 255 z = X + Y SetPixel Me.Picture1.hdc, X, Y, RGB(X, Y, z) Next Y Next X
End Sub
Private Sub Form_Load()
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Me.lblX = X Me.lblY = Y Me.lblCouleur = GetPixel(Me.Picture1.hdc, X, Y) End Sub
Quelqu'un peut il me dire pourquoi dans lblCouleur j'ai toujours -1 ?
Bonjour/soir,
Probablement parce que tu te situe en dehors de limites...
Essaye dans Private Sub Form_Load(): Picture1.ScaleMode = 3
Pour éviter qu'il ne travaille en twips.
Une autre solution est d'utiliser Point et/ou Pset à la place de Get et SetPixel.