How do I save the contents of a picture box?

pnh73
pnh73 used Ask the Experts™
on
I want to save the contents of a PictureBox which has had lines drawn on it etc. I want the user to save the image that is there. I have tried the following code:

---- Start of Code ----
Private Sub btnSavePicture_Click()
Dim sFile As String

 With dlgCommonDialog
        .DialogTitle = "Save Image As..."
        .CancelError = False
        .Filter = "Windows Bitmap Image (*.bmp)|*.bmp"
        .ShowOpen
        If Len(.FileName) = 0 Then
            Exit Sub
        End If
        sFile = .FileName
    End With

SavePicture picView.Image, sFile
sbStatusBar.SimpleText = "Picture saved to " & sFile
End Sub
---- End of Code ----

This saves a blank image for some reason, with the correct size 8-(

I hope you can help.

Paul

---------
P.S. When I minize and then restore, the image dissapears. I have a sub routine that draws the image, so could i set it to redraw on restoring of the window.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Try turning autoredraw on before drawing your picture

picture1.autoredraw = true

Commented:
The reason for this is that the image is the underlying memory bitmap.  Autoredraw automatically assigns the picture to the underlying bitmap when it is set to true.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial