问题描述
几年前,我在VB中创建了一个屏幕捕获工具,并每天使用它来编写报告.此后,我的笔记本电脑已更新为10级,并且捕获工具不再捕获可预测的图像.可以从vba(excel)运行该工具,而excel 传递捕获大小. 如果不存在excel链接,则该工具仅捕获预定义的大小. vb表单略透明,并设置为跟随鼠标. 单击鼠标时,该表单用于绑定一组像素以进行捕获 (即,表格后面的桌面像素变为图像).然后将图像传递到剪贴板以供使用.问题是捕获的图像不再等于表格后面的像素.我已经使用多次获胜10测试了该工具 机器都有相同的问题. 在右下角进行图像捕获时,图像捕获会与表单位置进一步偏移.我以为DPI规模可能是个问题,但运气介于100到150之间没有运气.我通常 由于我的屏幕分辨率而使用150.
I created a screen capture tool in VB a couple years ago and use it daily to write reports. My laptop has since been updated to win 10 and the capture tool no longer captures a predictable image. The tool can be run from vba (excel) where excel passes the capture size. If no excel link is present, the tool just captures a predefined size. The vb form is slightly transparent and is set to follow the mouse. When the mouse is clicked the form is used to bound a set of pixels for capture (ie the desktop pixels behind the form become the image). The image is then passed to the clipboard for use. The problem is that the capture image is no long equal to the pixels behind the form. I have tested the tool with multiple win 10 machines all have the same issue. The image capture becomes further offset from the form location when captures are take in the lower right corner. I thought DPI scale might be the issue, but no luck with anything from 100 to 150. I normally use 150 due to my screen res.
这是我认为是问题所在的代码:
Here is the code I believe is the issue:
Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles Me.MouseClick
Dim bounds As Form1
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
'capture screen bound by the form window
Me.Opacity = 0
bounds = Me
screenshot = New Bitmap(bounds.Width, bounds.Height, Imaging.PixelFormat.Format32bppRgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(Me.Bounds.X, Me.Bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
'set form background per screenshot and then pass to clipboard
Me.BackgroundImage = screenshot
Clipboard.Clear()
Dim bmp As Bitmap
bmp = Me.BackgroundImage
Clipboard.SetImage(bmp)
'tell excel the capture is complete
If sArg = "" Then
Else
Call notifyWbk()
End If
Me.Close()
End Sub
任何帮助将不胜感激.
Any help would be greatly appreciated.
推荐答案
这篇关于Windows 10的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!