Save BitBlt image

Can someone tell me how to save an image from a picture box that i have loaded into it using bitblt,i then need to UDP the data to another application which will then load up the pictuure,providing a screen shot of the clients computer,so i also need to know how so read and write files using the binary method as this never seems to work for me even though i have no problems with input and append.
LVL 13
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Erick37Connect With a Mentor Commented:
Set Picture1.Picture = Picture1.Image
SavePicture Picture1.Picture, "c:\pic.bmp"
You also have to set the AutoRedraw property of the picture box to True.
crazymanAuthor Commented:
That works great but how do i then break down the file and send it using UDP?
I can never seem to get the binary method to work.
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Please post a snippet of the code you are using to send and receive the file.
crazymanAuthor Commented:
This is what i was using but i seem to have solved the binary dillemma now so thanks for your help.

Private Sub CmdScreenShot_Click()
Dim wScreen As Long
Dim hScreen As Long
Dim w As Long
Dim h As Long
Dim a As Long
Dim intFile As Integer
Dim strFileLocation As String
Dim clpData As Clipboard
Dim bData() As Variant
    PicScreen.AutoRedraw = True
    strFileLocation = app.path & "\Pic.bmp"
    wScreen = Screen.Width \ Screen.TwipsPerPixelX
    hScreen = Screen.Height \ Screen.TwipsPerPixelY
    Picture1.ScaleMode = vbPixels
    w = Picture1.ScaleWidth
    h = Picture1.ScaleHeight
    hdcScreen = GetDC(0)
     StretchBlt PicScreen.hdc, 0, 0, w, h, hdcScreen, 0, 0, wScreen, hScreen, vbSrcCopy
    PicScreen.Picture = PicScreen.Image
    SavePicture PicScreen.Picture, strFileLocation
    PicScreen.AutoRedraw = False
    intFile = FreeFile
    ReDim bData(1 To 2)
    Open strFileLocation For Binary Access Read As #intFile
        Do While Not EOF(intFile)
            ReDim Preserve bData(LBound(bData) To UBound(bData) + 1)
            bData(UBound(bData)) = InputB(LOF(ntFile), intFile)
            Debug.Print bData(UBound(bData))
    Close #intFile
End Sub
Glad to help.
All Courses

From novice to tech pro — start learning today.