• Martes 14 de Mayo de 2024, 23:30

Autor Tema:  Capturar Una Region De La Pantalla?  (Leído 2107 veces)

waltergd22

  • Nuevo Miembro
  • *
  • Mensajes: 2
    • Ver Perfil
Capturar Una Region De La Pantalla?
« en: Viernes 16 de Abril de 2004, 21:30 »
0
Queria saber como puedo hacer para capturar una region de la pantalla y por ejemplo ponerla en un picture box.

desde ya muchas gracias

WALTER  :D

Hawk

  • Nuevo Miembro
  • *
  • Mensajes: 13
    • Ver Perfil
Re: Capturar Una Region De La Pantalla?
« Respuesta #1 en: Viernes 7 de Mayo de 2004, 20:44 »
0
hola fijate si esto se lo soluciona:

 :comp:

VERSION 5.00
Begin VB.Form frmPartialScreenShot
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Example of how to use modTakeScreenShot"
   ClientHeight    =   5772
   ClientLeft      =   36
   ClientTop       =   324
   ClientWidth     =   5388
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5772
   ScaleWidth      =   5388
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdFull
      Caption         =   "Take a &Full screenshot instead"
      Height          =   372
      Left            =   120
      TabIndex        =   11
      Top             =   5280
      Width           =   5172
   End
   Begin VB.CommandButton cmdScreenShot
      Caption         =   "&Click here to take a screenshot"
      Default         =   -1  'True
      Height          =   372
      Left            =   120
      TabIndex        =   8
      Top             =   4800
      Width           =   5172
   End
   Begin VB.PictureBox picScreenShot
      Height          =   3840
      Left            =   120
      ScaleHeight     =   3792
      ScaleWidth      =   5076
      TabIndex        =   10
      Top             =   840
      Width           =   5120
   End
   Begin VB.TextBox txtHeight
      Height          =   288
      Left            =   2640
      TabIndex        =   7
      Top             =   480
      Width           =   732
   End
   Begin VB.TextBox txtWidth
      Height          =   288
      Left            =   2640
      TabIndex        =   5
      Top             =   120
      Width           =   732
   End
   Begin VB.TextBox txtLeft
      Height          =   288
      Left            =   840
      TabIndex        =   3
      Top             =   480
      Width           =   732
   End
   Begin VB.TextBox txtTop
      Height          =   288
      Left            =   840
      TabIndex        =   1
      Top             =   120
      Width           =   732
   End
   Begin VB.Label lblNote
      Caption         =   "N.B. These values are in pixels."
      Height          =   492
      Left            =   3600
      TabIndex        =   9
      Top             =   240
      Width           =   1572
   End
   Begin VB.Label lblTop
      Caption         =   "&Top"
      Height          =   252
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   612
   End
   Begin VB.Label lblWidth
      Caption         =   "&Width"
      Height          =   252
      Left            =   1920
      TabIndex        =   4
      Top             =   120
      Width           =   612
   End
   Begin VB.Label lblHeight
      Caption         =   "&Height"
      Height          =   252
      Left            =   1920
      TabIndex        =   6
      Top             =   480
      Width           =   612
   End
   Begin VB.Label lblLeft
      Caption         =   "&Left"
      Height          =   252
      Left            =   120
      TabIndex        =   2
      Top             =   480
      Width           =   612
   End
End
Attribute VB_Name = "frmPartialScreenShot"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdFull_Click()
frmScreenShot.Show
frmPartialScreenShot.Hide
End Sub

Private Sub cmdScreenShot_Click()
On Error GoTo Err 'in case the .Text are not numeric
Dim Top As Long, Left As Long, Width As Long, Height As Long
Top = CLng(txtTop.Text)
Left = CLng(txtLeft.Text)
Width = CLng(txtWidth.Text)
Height = CLng(txtHeight.Text)
Call PartialScreenShot(picScreenShot.hDC, Top, Left, Width, Height)
Err:
End Sub

Private Sub txtTop_GotFocus()
txtTop.SelStart = 0
txtTop.SelLength = Len(txtTop.Text)
End Sub

Private Sub txtLeft_GotFocus()
txtLeft.SelStart = 0
txtLeft.SelLength = Len(txtLeft.Text)
End Sub

Private Sub txtWidth_GotFocus()
txtWidth.SelStart = 0
txtWidth.SelLength = Len(txtWidth.Text)
End Sub

Private Sub txtHeight_GotFocus()
txtHeight.SelStart = 0
txtHeight.SelLength = Len(txtHeight.Text)
End Sub

  :comp:

eso es para parcial screen es un archivo *.frm lo escribi haci para facilitar el evio :D
este de abajo es de el screen shot completo

 :comp:

VERSION 5.00
Begin VB.Form frmScreenShot
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Example of how to use modTakeScreenShot"
   ClientHeight    =   5052
   ClientLeft      =   36
   ClientTop       =   324
   ClientWidth     =   5376
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5052
   ScaleWidth      =   5376
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdPartial
      Caption         =   "Take a &Partial screenshot instead"
      Height          =   372
      Left            =   120
      TabIndex        =   2
      Top             =   4560
      Width           =   5172
   End
   Begin VB.CommandButton cmdScreenShot
      Caption         =   "&Click here to take a screenshot"
      Default         =   -1  'True
      Height          =   372
      Left            =   120
      TabIndex        =   0
      Top             =   4080
      Width           =   5172
   End
   Begin VB.PictureBox picScreenShot
      Height          =   3840
      Left            =   120
      ScaleHeight     =   3792
      ScaleWidth      =   5076
      TabIndex        =   1
      Top             =   120
      Width           =   5120
   End
End
Attribute VB_Name = "frmScreenShot"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdPartial_Click()
frmPartialScreenShot.Show
frmScreenShot.Hide
End Sub

Private Sub cmdScreenShot_Click()
Call ScreenShot(picScreenShot.hDC)
End Sub

 :comp:

 y aca va el modulo usado

 :comp:

Attribute VB_Name = "modTakeScreenShot"
Option Explicit

Public Declare Function BitBlt Lib "gdi32" (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
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long

Public Const SRCCOPY = &HCC0020

Public Sub ScreenShot(DestinationDC As Long)
Dim ScreenWidth As Long, ScreenHeight As Long, ScreenDC As Long, retval As Long
ScreenWidth = Screen.Width / Screen.TwipsPerPixelX
ScreenHeight = Screen.Height / Screen.TwipsPerPixelY
ScreenDC = GetDC(GetDesktopWindow)
retval = BitBlt(DestinationDC, 0, 0, ScreenWidth, ScreenHeight, ScreenDC, 0, 0, SRCCOPY)
End Sub

Public Sub PartialScreenShot(DestinationDC As Long, Top As Long, Left As Long, Width As Long, Height As Long)
Dim ScreenDC As Long, retval As Long
ScreenDC = GetDC(GetDesktopWindow)
retval = BitBlt(DestinationDC, 0, 0, Width, Height, ScreenDC, Top, Left, SRCCOPY)
End Sub

 :comp:
che entre la computadoritas esta el codigo para diferencialo a simple vista.
bueno espero que te sive, che conta si te funciona para saber. bueno caulquier cosa ya sabes donde preguntar.
Suerte  :hola:  
                                 Hawk