Results 1 to 5 of 5

Thread: imagebox problem

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    england
    Posts
    87

    imagebox problem

    ive used setpixelv to set a picture into a picturebox.

    as i want to use the stretch feature of the imagebox i tried :

    image1 = picture1

    but it seems i could not get the picture to appear on the imagebox.

    i've notice that imagebox uses vbtwip and picturebox uses pixels, could this be the problem ?

    i did get a few values into the first few pixels of the imagebox after checking it but still cant see a thing.

    someone please help !!

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You need to make sure the added Pixels are Persistent (stay there as part of the "Picture"), i.e.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
    4.  
    5. Private Sub Form_Load()
    6.     ' Make the Image Box Twice the Size of the Picturebox
    7.     ' And set it to Stretch it's Contents to Fit
    8.     With Picture1
    9.         Image1.Move .Left + .Width, .Top, .Width * 2, .Height * 2
    10.         Image1.Stretch = True
    11.     End With
    12. End Sub
    13.  
    14. Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    15.     If Button = vbLeftButton Then
    16.         With Picture1
    17.             .AutoRedraw = True  ' Make sure the Pixels Persist
    18.             Call SetPixelV(.hdc, .ScaleX(x, .ScaleMode, vbPixels), .ScaleY(y, .ScaleMode, vbPixels), vbBlack)
    19.             ' Transfer the Edited "Image" to the "Picture"
    20.             .Picture = .Image
    21.             ' Now you can assign the Picture to the Image Control
    22.             Image1 = .Picture
    23.         End With
    24.     End If
    25. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    england
    Posts
    87
    Ahhhhh....it works

    Thanks man !

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    england
    Posts
    87
    does anyone know how to get the value of the pixels in a imagebox ?

    used windows api getpixel for picturebox but cant get it to work with imagebox.

    any tips ?

  5. #5
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    well get the dc and get it from there. not a to great way to do it, but it works. But I am sure you could somehow find the real dc to it in the properties or through api.
    Sanity is a full time job

    Puh das war harter Stoff!

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