Results 1 to 6 of 6

Thread: SetPixel

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    7

    Lightbulb

    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.

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    It works fine for me.
    What kind of a variable is lnrRet. It should be declared as Long.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    7

    Angry

    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.

  4. #4
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    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}

  5. #5
    Guest
    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

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Posts
    7

    Talking

    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
  •  



Click Here to Expand Forum to Full Width