扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
VB.NT用的是触发事件,一按就会触发,要不你加个timer控件,延迟一秒
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名申请、虚拟主机、营销软件、网站建设、青神网站维护、网站推广。
标题的问题:你先把图片保存,再加载
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 Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
'窗口上要放一个图片框和一个时钟控件。办法是把屏幕拷贝到图片框,再把图片框的Image保存到文件。
Private Sub Form_Load()
If Dir("D:\截图", vbDirectory) = "" Then MkDir "D:\截图"
Timer1.Enabled = False
Timer1.Interval = 1000
Picture1.Move 0, 0, Screen.Width, Screen.Height
Picture1.AutoRedraw = True
Picture1.Visible = False
End Sub
Private Sub Command1_Click()
Me.WindowState = vbMinimized '开始后把窗口最小化,否则自己也会拷贝进去
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static imgIndex As Long
imgIndex = imgIndex + 1
BitBlt Picture1.hDC, 0, 0, Screen.Width \ Screen.TwipsPerPixelX, Screen.Height \ Screen.TwipsPerPixelY, GetDC(0), 0, 0, vbSrcCopy
SavePicture Picture1.Image, "D:\截图\" imgIndex ".bmp"
End Sub
[DllImport("user32.dll", EntryPoint = "GetDC")]
public static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "ReleaseDC")]
public static extern IntPtr ReleaseDC(IntPtr hWnd, IntPtr hDC);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
先找到你要截图的那个窗体的 句柄 然后根据这个句柄得到改窗体的DC 创建一个bitmap 然后填充 得到的bitmap后 显示到picturebox里面
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流