JoostVersteegen
Nieuwe gebruiker
- Lid geworden
- 7 dec 2007
- Berichten
- 1
I have a Form with a Picturebox viewport, containing controls (pictureboxes, lines and labels).I try to make a bitmap of it using the code below (I do not use screencapture for it will only sho the visible part):
Private Sub mnu_Report_Click()
'// get picture and save to disk
PicPath = App.Path & EXPORT_PATH & "\" & mProdFlowConfName & ".bmp"
Picture1.AutoSize = True
Call CreatePicture(mViewPort.Container, Picture1)
Call VB.SavePicture(Picture1.Image, PicPath)
'// add picture to report
Call Rpt.AddPicToReport(PicPath)
End Sub
Private Sub CreatePicture(Src As PictureBox, Dst As PictureBox)
Dim rv As Long
Dim box As IBox
Dim MaxX As Long
Dim MaxY As Long
On Error GoTo exception
'// determine max size
For Each box In mOperStepContainer
If box.Left > MaxX Then MaxX = box.Left
If box.Top > MaxY Then MaxY = box.Top
Next
MaxX = MaxX + 1000
MaxY = MaxY + 1000
'// create picture
Src.SetFocus
Dst.Move 0, 0, MaxX, MaxY
Dst.AutoRedraw = True
Call SendMessage(Src.hWnd, WM_PAINT, Dst.hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)
Call SendMessage(Src.hWnd, WM_PRINT, Dst.hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)
Dst.Picture = Dst.Image
Dst.AutoRedraw = False
Dst.Refresh
Exit Sub
exception:
ShowError Err.Description, TypeName(Me), "CreatePicture()"
End Sub
The code gives me a bitmap with the client Pictureboxes, but they have no picture in it.
Does anyone have suggestions as how to make the pictureboxes show their picture in the resulting bitmap?
Thanks, Joost
Private Sub mnu_Report_Click()
'// get picture and save to disk
PicPath = App.Path & EXPORT_PATH & "\" & mProdFlowConfName & ".bmp"
Picture1.AutoSize = True
Call CreatePicture(mViewPort.Container, Picture1)
Call VB.SavePicture(Picture1.Image, PicPath)
'// add picture to report
Call Rpt.AddPicToReport(PicPath)
End Sub
Private Sub CreatePicture(Src As PictureBox, Dst As PictureBox)
Dim rv As Long
Dim box As IBox
Dim MaxX As Long
Dim MaxY As Long
On Error GoTo exception
'// determine max size
For Each box In mOperStepContainer
If box.Left > MaxX Then MaxX = box.Left
If box.Top > MaxY Then MaxY = box.Top
Next
MaxX = MaxX + 1000
MaxY = MaxY + 1000
'// create picture
Src.SetFocus
Dst.Move 0, 0, MaxX, MaxY
Dst.AutoRedraw = True
Call SendMessage(Src.hWnd, WM_PAINT, Dst.hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)
Call SendMessage(Src.hWnd, WM_PRINT, Dst.hDC, PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED)
Dst.Picture = Dst.Image
Dst.AutoRedraw = False
Dst.Refresh
Exit Sub
exception:
ShowError Err.Description, TypeName(Me), "CreatePicture()"
End Sub
The code gives me a bitmap with the client Pictureboxes, but they have no picture in it.
Does anyone have suggestions as how to make the pictureboxes show their picture in the resulting bitmap?
Thanks, Joost