vb抓图怎么放进picturebox??

来源:百度知道 编辑:UC知道 时间:2024/05/15 08:48:46
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
‘获得窗口句柄用于抓图
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
‘释放窗口句柄
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
‘绘图到某个句柄上
Me.Hide
DoEvents

'设定窗体大小
Me.Top = 0
Me.Left = 0
Me.Width = Screen.Width
Me.Height = Screen.Height
Me.AutoRedraw = True
hc = GetDC(0)
sx = Screen.Width \ Screen.TwipsPerPixelX
sy = Screen.Height \ Screen.TwipsPerPixelY
'我抓
BitBlt Me.hdc, 0, 0, sx, sy, hc, 0, 0, vbSrcCopy
ReleaseDC 0, hc
Me.AutoRedraw = False
'显示
Me.Show
这是一些代码.请帮我解释一下行吗??还有怎样在这些的基础上把截得的图象放进picturebox里??

Option Explicit
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Sub Command1_Click()
keybd_event vbKeySnapshot, 0&, 0&, 0&
DoEvents
Picture1.Picture = Clipboard.GetData(vbCFBitmap)
End Sub

Picture1.AutoRedraw = True
BitBlt Picture1.hdc, 0, 0, sx, sy, hc, 0, 0, vbSrcCopy