hi all
i'm wondering if it's possible for me to capture certain amount of my screan at an interval, compress it and send it accross a socket?
kindof like vnc...
is it possible in vb?
thanks
Printable View
hi all
i'm wondering if it's possible for me to capture certain amount of my screan at an interval, compress it and send it accross a socket?
kindof like vnc...
is it possible in vb?
thanks
it would not be easy to do, but, as you may have guessed, anything is possible. these programs tend to only send the data that has changed. this makes the job a lot easier, as usually not too much of the screen changes.
Of course, if you are transferring graphical data, as opposed to text, it is that much harder! :wave:
Capture a part of the screen is easy, sending it across a socket is also fairly simple. Then we come to the compression part... If you capture a part (or all) of the screen VB will store it as an uncompressed bitmap file. You could use some third party tool to compress it to a JPG or GIF before sending it but you probably need to store it as a file on disk first which also takes time.
Here's a quick example on how to store a part of the screen and show it in a picture box on a form.
Cheers,VB Code:
Private Declare Function GetDesktopWindow _ Lib "user32.dll" () As Long Private Declare Function GetDC _ Lib "user32.dll" ( _ ByVal hwnd As Long) As Long Private Declare Function ReleaseDC _ Lib "user32.dll" ( _ ByVal hwnd As Long, _ ByVal hdc As Long) As Long Private Declare Function BitBlt _ Lib "gdi32.dll" ( _ ByVal hDestDC As Long, _ ByVal x As Long, _ ByVal y As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long, _ ByVal hSrcDC As Long, _ ByVal xSrc As Long, _ ByVal ySrc As Long, _ ByVal dwRop As Long) As Long Private Sub Form_Load() With Picture1 .ScaleMode = vbPixels 'for easier calculations .AutoRedraw = True End With End Sub Private Sub Command1_Click() Capture 10, 10 End Sub Private Sub Capture(ByVal x As Long, ByVal y As Long) 'We capture the screen at position x,y and 'use the width and height of the picture box Dim hDesktopDC As Long, hDesktopWnd As Long hDesktopWnd = GetDesktopWindow hDesktopDC = GetDC(hDesktopWnd) With Picture1 BitBlt .hdc, 0, 0, .ScaleWidth, .ScaleHeight, hDesktopDC, x, y, vbSrcCopy .Refresh End With ReleaseDC hDesktopWnd, hDesktopDC End Sub
it's much easier sending text only.
That's true... and that a fish enjoys water is also true :)Quote:
Originally Posted by dglienna