PDA

Click to See Complete Forum and Search --> : Copy image from picture box


zabrucewayne
Sep 26th, 2002, 11:34 AM
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

Grimfort
Sep 26th, 2002, 02:15 PM
Ask john, he might know :)

Sheppe
Sep 26th, 2002, 03:13 PM
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.

Grimfort
Sep 26th, 2002, 03:41 PM
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.