7,763
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command4_Click() '单点一下按钮大多数情况都是全黑的
Text2.Text = PrintWindow(Val(Text1.Text), Picture1.hDC, 0)
Picture1.Refresh
Text3.Text = GetPixel(Picture1.hDC, 100, 100)
End Sub
Private Sub Timer1_Timer() '我用了个Timer,间隔1毫秒,如果截图不是全黑,就停。这样大概过几秒就能截到图。时间也不准,有时候长有时候短的
Call Command4_Click
If Text3.Text <> "0" Then
Timer1.Enabled = False
End If
End Sub
Private Sub Form_Load()
Picture1.AutoRedraw = True
End Sub
Option Explicit
Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long
Private 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
Private Sub Command1_Click()
Dim a
a = PrintWindow(395116, Picture1.hDC, 0)
BitBlt Picture2.hDC, 0, 0, 300, 300, Picture1.hDC, 0, 0, vbSrcCopy
SavePicture Picture2.Image, "c:\aaa.bmp"
End Sub