蓝老师好!
页签中的PictureBox控件换成WebBrowser就不行了,如果起始页签是2,3,4,截图也不对,是什么原因?
实例中双击窗口中的行,调出截图窗口。
谢谢!
'代码如下:
With Tables("错题数据_table1")
e.Form.Controls("TabControl1").SelectedIndex = 1
Application.Doevents
Dim trv = e.Form.Controls("WebBrowser1").BaseControl
Dim point As Point = e.Form.controls("tabcontrol1").basecontrol.PointToScreen(trv.Bounds.Location)
Dim myGraphics As Graphics = basemainform.CreateGraphics()
Dim s As new Size(trv.width-20, trv.height-50) '截取的大小-不要改50
Dim bit As New Bitmap(s.Width, s.Height , myGraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(bit)
memoryGraphics.CopyFromScreen(point.x+4, point.y+50, 0, 0, s) '截取的开始位置,坐标(100, 200)
bit.save(ProjectPath & "Attachments\错题\" & Tables("错题数据_table1").Current("编号") & "TM" & ".jpg")
.current("题目图片文件") = .Current("编号") & "TM" & ".jpg"
memoryGraphics.dispose
myGraphics.dispose
bit.dispose
Forms("错题数据").Controls("PictureBox1").ImageFile = ""
Forms("错题数据").Controls("PictureBox1").ImageFile = ProjectPath & "Attachments\错题\" & Tables("错题数据_table1").Current("编号") & "TM" & ".jpg"
e.Form.Controls("TabControl1").SelectedIndex = 0
Application.Doevents
Dim trv1 = e.Form.Controls("WebBrowser2").BaseControl
Dim point1 As Point = e.Form.controls("tabcontrol1").basecontrol.PointToScreen(trv1.Bounds.Location)
Dim myGraphics1 As Graphics = basemainform.CreateGraphics()
Dim s1 As new Size(trv1.width-20, trv1.height-50) '截取的大小
Dim bit1 As New Bitmap(s1.Width, s1.Height , myGraphics1)
Dim memoryGraphics1 As Graphics = Graphics.FromImage(bit1)
memoryGraphics1.CopyFromScreen(point1.x+4, point1.y+50, 0, 0, s1) '截取的开始位置,坐标(100, 200)
bit1.save(ProjectPath & "Attachments\错题\" & Tables("错题数据_table1").Current("编号") & "DA" & ".jpg") '很奇怪,应该是DA,却要改为TM
.current("答案图片文件") = .Current("编号") & "DA" & ".jpg"
memoryGraphics1.dispose
myGraphics1.dispose
bit1.dispose
Forms("错题数据").Controls("PictureBox2").ImageFile = ""
Forms("错题数据").Controls("PictureBox2").ImageFile = ProjectPath & "Attachments\错题\" & Tables("错题数据_table1").Current("编号") & "DA" & ".jpg"
End With
msgbox("已保存!")
此主题相关图片如下:截屏图片 (1).jpg
