Results 1 to 4 of 4

Thread: Copy image from picture box

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2002
    Posts
    1

    Question Copy image from picture box

    Can anyone tell me how to copy the image of a picture box INCLUDING the images of all child picture boxes.

    I have tried SendMessage with Pain/ Print which copies the picture into the destination picturebox, but this excludes all child pictureboxes. The code for this follows.

    I have also tried bitblt unsucessfully as the image I want is bigger than the screen.

    Any help would be appreciated!


    Private Declare Function SendMessage Lib "user32" Alias _
    "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, ByVal lParam As Long) As Long

    Private Const WM_PAINT = &HF
    Private Const WM_PRINT = &H317
    Private Const PRF_CLIENT = &H4&
    Private Const PRF_CHILDREN = &H10&
    Private Const PRF_OWNED = &H20&

    Private Sub Command1_Click()
    Picture1.AutoRedraw = True
    Picture2.AutoRedraw = True
    Picture2.Width = Picture1.Width
    Picture2.Height = Picture1.Height
    CaptureWnd Picture1.hwnd, Picture2.hDC
    Picture2.Refresh
    End Sub

    Private Sub CaptureWnd(inWnd As Long, outDC As Long)
    SendMessage inWnd, WM_PAINT, outDC, &H0
    SendMessage inWnd, WM_PRINT, outDC, _
    PRF_CHILDREN + PRF_CLIENT + PRF_OWNED
    End Sub

  2. #2
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Ask john, he might know

  3. #3
    Addicted Member Sheppe's Avatar
    Join Date
    Sep 2002
    Location
    Kelowna, BC
    Posts
    245
    What do you want to copy it to? Try using the Image (not Picture) property. I believe that's the name of it. If it isn't then just scroll through the property list and it should stand out.
    [vbcode]
    On Error Goto Hell
    [/vbcode]
    Sheppe Pharis, MCSD
    Check out http://www.vb-faq.com
    Click here for access to the free Code-Express source code and component sharing network for VB6
    Want a better way to skin your .NET applications? Click here!

  4. #4
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    No its more complicated then that.

    Theres a picture box thats bigger then the screen (its huge actually).

    We need to print the picturebox, and all its controls. Bitblt only gets whats on screen, not whats also off. But we need to pass back the picutre box somewhere else (dont ask) so it needs to be created as a new picutre in memory.

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