Click to See Complete Forum and Search --> : SetPixel
Lechugas
Jan 23rd, 2001, 09:41 PM
I have a picturebox in a project and I have to plot some pixels on it. This picturebox has a scale. Instead of using picture.pset I would like to use the SetPixel API, could anyone explain me how to use it?
I tried this but it does not work
lnrRet = SetPixel(picture.hdc, x, y, 200)
Thanks,
Nicolas
Things must be easy, but not easier than they are.
Vlatko
Jan 24th, 2001, 08:49 AM
It works fine for me.
What kind of a variable is lnrRet. It should be declared as Long.
Lechugas
Jan 24th, 2001, 10:08 AM
Sorry, it was lngRet, a long variable, but it does not work for me. I mean, it plots a pixel, but in the wrong coordinate. If I plot it at 100, 100 and the picture has a scale of 100 and 100 will it plot it at 100,100 according to the scale of the picturebox? If yes, it's fine, cause this is what I am looking for.
Could you send me your code?
Am I missing anything??
Thanks,
Nicolas
YoungBuck
Jan 24th, 2001, 11:15 AM
Did you convert the x and y values to pixels correctly, if you have customized the Scale to fit your needs then you will still have to convert the values for x an y back to pixels before you call SetPixel.
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 Sub Form_Load()
Picture1.AutoRedraw = True
Picture1.ScaleMode = vbPixels
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
SetPixel Picture1.hdc, x, y, vbBlack
Picture1.Refresh
End Sub
Lechugas
Jan 24th, 2001, 08:01 PM
OK thanks a lot, I will try that.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.