怎样截取任意的画面的一部分
来源:百度知道 编辑:UC知道 时间:2024/09/13 00:02:01
QQ带了截图功能
默认的快截键是Ctrl + Alt + A
在QQ的系统设置里有设置参数,如分辨率等.
三个API搞定
Private Declare Function CreateDCA& Lib "gdi32" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As Long)
Private Declare Function BitBlt Lib "gdi32" Alias "BitBlt" (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 Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
第一个用来获取整个屏幕的DC
Dim DC As Long
DC = CreateDCA("DISPLAY", vbNullString, vbNullString, 0)
然后用BitBlt把屏幕的某部分画到窗体或者PICTUREBOX就行了.
BitBlt Me.hDC, 0, 0, 50, 50, DC, 0, 0, vbSrcCopy
最后关闭窗体前最后把生成的DC用DeleteDC删除
DeleteDC DC