[RESOLVED] LaVolpe AlphaImgControl - Capture Picbox To AIC...
I have controls inside a PictureBox. I am capturing the PictureBox with controls as an Image and would like to set that image to the AlphaImgControl, but it keeps telling me that it's an invalid picture. Need the captured image in the AlphaImgControl and would like to do so without file-saving. Any ideas?
Re: LaVolpe AlphaImgControl - Capture Picbox To AIC...
If picbox AutoRedraw is set true, try passing: picbox.Image. Otherwise, show the code you are using to assign it to the AIC
Re: LaVolpe AlphaImgControl - Capture Picbox To AIC...
Code:
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& ' Draw the window's client area
Private Const PRF_CHILDREN = &H10& ' Draw all visible child
Private Const PRF_OWNED = &H20& ' Draw all owned windows
Code:
Dim rv As Long
Picture2.AutoRedraw = True
rv = SendMessage(Picture1.hWnd, WM_PAINT, Picture2.hDC, 0)
rv = SendMessage(Picture1.hWnd, WM_PRINT, Picture2.hDC, PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
Set Picture2.Picture = Picture2.Image
The following gives me the error "Invalid Picture"
Code:
Alpha.Picture = LoadPictureGDIplus(Picture2.Picture)
Re: LaVolpe AlphaImgControl - Capture Picbox To AIC...
When a picture property is passed, the control attempts to use the picture's function .SaveAsFile to write the image to a stream. I've had intermittent failures with that function failing to return a stream. In your case, the solution is easier since no transparency is in play... Pass the bitmap handle:
Alpha.Picture = LoadPictureGDIplus(Picture2.Picture.Handle)
Re: LaVolpe AlphaImgControl - Capture Picbox To AIC...