me encontre este code navegando y me han surgido unas dudas, como puedo hacer que al capturar la pantalla mediante winsock (estoy trabajando en una aplicacio cliente-servidor) el servidor me envie la captura de pantalla que realizo pq el cliente recibe la instruccion de capturar, ese no es problema pq yo lo hice, lo que me tiene loko es lo del envio de la imagen. como puedo hacerlo....
lo estoy tratando asi..
este es un code del servidor....
*************************************************
Case "screen2": Set Picture1.Picture = CaptureScreen()
Dim imagen As PictureBox
Winsock1.SendData imagen
**************************************************
bueno y en el server lo estoy tratando de recibir asi...
**************************************************
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
On Error GoTo error
Dim datos As String
'Text1.Text = Text1.Text & Chr(10)
Winsock1.GetData datos
Text2.Text = Text2.Text + datos & vbCrLf
Dim imagen As PictureBox
Winsock1.GetData imagen
Picture1.Picture = Picture1.Picture + imagen
Exit Sub
error: MsgBox "Error Recibiendo datos.", vbCritical
End Sub
************************************************** *
pero siempre me da error..
bueno aqui el code..
salu2
Option Explicit
Option Base 0
Private Type PALETTEENTRY
peRed As Byte
peGreen As Byte
peBlue As Byte
peFlags As Byte
End Type
Private Type LOGPALETTE
palVersion As Integer
palNumEntries As Integer
palPalEntry(255) As PALETTEENTRY ' Enough for 256 colors
End Type
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
#If Win32 Then
Private Const RASTERCAPS As Long = 38
Private Const RC_PALETTE As Long = &H100
Private Const SIZEPALETTE As Long = 104
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function CreateCompatibleDC Lib "GDI32" ( _
ByVal hDC As Long) As Long
Private Declare Function CreateCompatibleBitmap Lib "GDI32" ( _
ByVal hDC As Long, ByVal nWidth As Long, _
ByVal nHeight As Long) As Long
Private Declare Function GetDeviceCaps Lib "GDI32" ( _
ByVal hDC As Long, ByVal iCapabilitiy As Long) As Long
Private Declare Function GetSystemPaletteEntries Lib "GDI32" ( _
ByVal hDC As Long, ByVal wStartIndex As Long, _
ByVal wNumEntries As Long, lpPaletteEntries As PALETTEENTRY) _
As Long
Private Declare Function CreatePalette Lib "GDI32" ( _
lpLogPalette As LOGPALETTE) As Long
Private Declare Function SelectObject Lib "GDI32" ( _
ByVal hDC As Long, ByVal hObject As Long) As Long
Private Declare Function BitBlt Lib "GDI32" ( _
ByVal hDCDest As Long, ByVal XDest As Long, _
ByVal YDest As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal hDCSrc As Long, _
ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) _
As Long
Private Declare Function DeleteDC Lib "GDI32" ( _
ByVal hDC As Long) As Long
Private Declare Function GetForegroundWindow Lib "USER32" () _
As Long
Private Declare Function SelectPalette Lib "GDI32" ( _
ByVal hDC As Long, ByVal hPalette As Long, _
ByVal bForceBackground As Long) As Long
Private Declare Function RealizePalette Lib "GDI32" ( _
ByVal hDC As Long) As Long
Private Declare Function GetWindowDC Lib "USER32" ( _
ByVal hWnd As Long) As Long
Private Declare Function GetDC Lib "USER32" ( _
ByVal hWnd As Long) As Long
Private Declare Function GetWindowRect Lib "USER32" ( _
ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function ReleaseDC Lib "USER32" ( _
ByVal hWnd As Long, ByVal hDC As Long) As Long
Private Declare Function GetDesktopWindow Lib "USER32" () As Long
Private Type PicBmp
Size As Long
Type As Long
hBmp As Long
hPal As Long
Reserved As Long
End Type
Private Declare Function OleCreatePictureIndirect _
Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, _
ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
#ElseIf Win16 Then
Private Const RASTERCAPS As Integer = 38
Private Const RC_PALETTE As Integer = &H100
Private Const SIZEPALETTE As Integer = 104
Private Type RECT
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
End Type
Private Declare Function CreateCompatibleDC Lib "GDI" ( _
ByVal hDC As Integer) As Integer
Private Declare Function CreateCompatibleBitmap Lib "GDI" ( _
ByVal hDC As Integer, ByVal nWidth As Integer, _
ByVal nHeight As Integer) As Integer
Private Declare Function GetDeviceCaps Lib "GDI" ( _
ByVal hDC As Integer, ByVal iCapabilitiy As Integer) As Integer
Private Declare Function GetSystemPaletteEntries Lib "GDI" ( _
ByVal hDC As Integer, ByVal wStartIndex As Integer, _
ByVal wNumEntries As Integer, _
lpPaletteEntries As PALETTEENTRY) As Integer
Private Declare Function CreatePalette Lib "GDI" ( _
lpLogPalette As LOGPALETTE) As Integer
Private Declare Function SelectObject Lib "GDI" ( _
ByVal hDC As Integer, ByVal hObject As Integer) As Integer
Private Declare Function BitBlt Lib "GDI" ( _
ByVal hDCDest As Integer, ByVal XDest As Integer, _
ByVal YDest As Integer, ByVal nWidth As Integer, _
ByVal nHeight As Integer, ByVal hDCSrc As Integer, _
ByVal XSrc As Integer, ByVal YSrc As Integer, _
ByVal dwRop As Long) As Integer
Private Declare Function DeleteDC Lib "GDI" ( _
ByVal hDC As Integer) As Integer
Private Declare Function GetForegroundWindow Lib "USER" _
Alias "GetActiveWindow" () As Integer
Private Declare Function SelectPalette Lib "USER" ( _
ByVal hDC As Integer, ByVal hPalette As Integer, ByVal _
bForceBackground As Integer) As Integer
Private Declare Function RealizePalette Lib "USER" ( _
ByVal hDC As Integer) As Integer
Private Declare Function GetWindowDC Lib "USER" ( _
ByVal hWnd As Integer) As Integer
Private Declare Function GetDC Lib "USER" ( _
ByVal hWnd As Integer) As Integer
Private Declare Function GetWindowRect Lib "USER" ( _
ByVal hWnd As Integer, lpRect As RECT) As Integer
Private Declare Function ReleaseDC Lib "USER" ( _
ByVal hWnd As Integer, ByVal hDC As Integer) As Integer
Private Declare Function GetDesktopWindow Lib "USER" () As Integer
Private Type PicBmp
Size As Integer
Type As Integer
hBmp As Integer
hPal As Integer
Reserved As Integer
End Type
Private Declare Function OleCreatePictureIndirect _
Lib "oc25.dll" (PictDesc As PicBmp, RefIID As GUID, _
ByVal fPictureOwnsHandle As Integer, IPic As IPicture) _
As Integer
#End If
'1. Start a new project. Form1 is created by default.
'2. Place six CommandButtons on the form along the left side.
'3. Place one picture box on the form to the right of the buttons.
'4. Put the following code in Form1:
'--------------------------------------------------------------------
' Capture the entire screen
Private Sub Command1_Click()
Set Picture1.Picture = CaptureScreen()
End Sub
' Capture the entire form including title and border
Private Sub Command2_Click()
Set Picture1.Picture = CaptureForm(Me)
End Sub
' Capture the client area of the form
Private Sub Command3_Click()
Set Picture1.Picture = CaptureClient(Me)
End Sub
' Capture the active window after two seconds
Private Sub Command4_Click()
MsgBox "Two seconds after you close this dialog " & _
"the active window will be captured."
' Wait for two seconds
Dim EndTime As Date
EndTime = DateAdd("s", 2, Now)
Do Until Now > EndTime
DoEvents
Loop
Set Picture1.Picture = CaptureActiveWindow()
' Set focus back to form
Me.SetFocus
End Sub
' Print the current contents of the picture box
Private Sub Command5_Click()
PrintPictureToFitPage Printer, Picture1.Picture
Printer.EndDoc
End Sub
' Clear out the picture box
Private Sub Command6_Click()
Set Picture1.Picture = Nothing
End Sub
' Initialize the form and controls
Private Sub Form_Load()
Me.Caption = "Capture and Print Example"
Command1.Caption = "&Screen"
Command2.Caption = "&Form"
Command3.Caption = "&Client"
Command4.Caption = "&Active"
Command5.Caption = "&Print"
Command6.Caption = "C&lear"
Picture1.AutoSize = True
End Sub
'--------------------------------------------------------------------
'5. Add a new standard module to the project (module1 by default).
'6. Put the following code in the new module:
'--------------------------------------------------------------------
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''
'
' Visual Basic 4.0 16/32 Capture Routines
'
' This module contains several routines for capturing windows into a
' picture. All the routines work on both 16 and 32 bit Windows
' platforms.
' The routines also have palette support.
'
' CreateBitmapPicture - Creates a picture object from a bitmap and
' palette
' CaptureWindow - Captures any window given a window handle
' CaptureActiveWindow - Captures the active window on the desktop
' CaptureForm - Captures the entire form
' CaptureClient - Captures the client area of a form
' CaptureScreen - Captures the entire screen
' PrintPictureToFitPage - prints any picture as big as possible on
' the page
'
' NOTES
' - No error trapping is included in these routines
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''
'
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''
'
' CreateBitmapPicture
' - Creates a bitmap type Picture object from a bitmap and palette
'
' hBmp
' - Handle to a bitmap
'
' hPal
' - Handle to a Palette
' - Can be null if the bitmap doesn't use a palette
'
' Returns
' - Returns a Picture object containing the bitmap
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''