|
-
Jan 23rd, 2001, 10:41 PM
#1
Thread Starter
New Member
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.
Things must be easy, but not easier than they are.
-
Jan 24th, 2001, 09:49 AM
#2
Frenzied Member
It works fine for me.
What kind of a variable is lnrRet. It should be declared as Long.
-
Jan 24th, 2001, 11:08 AM
#3
Thread Starter
New Member
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
Things must be easy, but not easier than they are.
-
Jan 24th, 2001, 12:15 PM
#4
Fanatic Member
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.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Jan 24th, 2001, 03:40 PM
#5
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 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
-
Jan 24th, 2001, 09:01 PM
#6
Thread Starter
New Member
OK thanks a lot, I will try that.
Things must be easy, but not easier than they are.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|