2 Replies - 1088 Views - Last Post: 04 February 2013 - 08:15 AM Rate Topic: -----

#1 namek0e2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-January 13

VB.net Screen Capture Image Problem!

Posted 03 February 2013 - 11:53 PM

Good day dreamincoders

here's my problem:

i always get half or 1/3 of the image when i'm taking a screen capture.

here's my code on server form

dim bytedata(100000) as byte
Private Sub OnReceived(ByVal ar As IAsyncResult)
        Dim client As Socket = ar.AsyncState
        client.EndReceive(ar)
        Dim bytesRec As Byte() = bytedata
        Dim message As String = System.Text.ASCIIEncoding.ASCII.GetString(bytesRec)
        If caps = 1 Then
            caps = 0
            Dim path As String
            path = System.Windows.Forms.Application.StartupPath.ToString() + "\T1.Bmp"
            Dim fli As New FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)
            fli.Write(bytesRec, 0, bytesRec.Length)
            fli.Close()
            Dim s As New FileStream(path, FileMode.Open, FileAccess.Read)
            PictureBox1.Image = Image.FromStream(s)
            s.Close()
        End If
        Read(message)
        'sortDelim()
        Array.Clear(bytedata, 0, bytedata.Length)
        clientSocket.BeginReceive(bytedata, 0, bytedata.Length, SocketFlags.None, _
                                  New AsyncCallback(AddressOf OnReceived), clientSocket)
        clientSocket = ar.AsyncState



and here's for client
 Private Sub capturenow()
        Timer1.Enabled = True
    End Sub

 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        CaptureScreen()
        Dim b(10000000) As Byte
        Dim path As String
        path = System.Windows.Forms.Application.StartupPath.ToString() + "\T1.bmp"
        oBackground.Save(path)
        Dim fl As New FileStream(path, FileMode.Open, FileAccess.Read)
        Dim l As Integer
        l = fl.Read(b, 0, fl.Length)
        fl.Close()
        clientSocket.Send(b, l, SocketFlags.None)
        File.Delete(path)
        Timer1.Enabled = False
    End Sub

    Private Sub CaptureScreen()
        Dim hSDC, hMDC As Integer
        Dim hBMP, hBMPOld As Integer
        Dim r As Integer
        hSDC = CreateDC("DISPLAY", "", "", "")
        hMDC = CreateCompatibleDC(hSDC)
        FW = GetDeviceCaps(hSDC, 8)
        FH = GetDeviceCaps(hSDC, 10)
        hBMP = CreateCompatibleBitmap(hSDC, FW, FH)
        hBMPOld = SelectObject(hMDC, hBMP)
        r = BitBlt(hMDC, 0, 0, FW, FH, hSDC, 0, 0, 13369376)
        hBMP = SelectObject(hMDC, hBMPOld)
        r = DeleteDC(hSDC)
        r = DeleteDC(hMDC)
        oBackground = Image.FromHbitmap(New IntPtr(hBMP))
        DeleteObject(hBMP)
    End Sub




the output image attached here is the image i always received in picturebox1 of server. please help me seniors thanks.

Posted Image

Is This A Good Question/Topic? 0
  • +

Replies To: VB.net Screen Capture Image Problem!

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6534
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: VB.net Screen Capture Image Problem!

Posted 04 February 2013 - 07:18 AM

So your chat program is taking timed screenshots of the client's monitor and sending them back to the server?!?!?!?

SPYWARE

You just made my personal watch list for every post you create.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14088
  • View blog
  • Posts: 56,440
  • Joined: 12-June 08

Re: VB.net Screen Capture Image Problem!

Posted 04 February 2013 - 08:15 AM

Agreed. THis is textbook app that says it does one thing, but then turns around and sends back screenshots of the user as the real intent.

I am going to close this topic. OP do not persist in asking for help along these lines - no one likes spyware and we won't help you. If you have questions feel free to shoot me a PM.

Closing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1