Foxtable(狐表)用户栏目专家坐堂 → [求助]控件截图


  共有2424人关注过本帖树形打印复制链接

主题:[求助]控件截图

帅哥哟,离线,有人找我吗?
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/19 12:03:00 [显示全部帖子]

'截取第一个页面
e.Form.Controls("TabControl1").SelectedIndex = 1   
Application.Doevents
Dim trv = e.Form.Controls("PictureBox1").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-60) '截取的大小
Dim bit As New Bitmap(s.Width, s.Height , myGraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(bit)
memoryGraphics.CopyFromScreen(point.x+4, point.y+55, 0, 0, s) '截取的开始位置,坐标(100, 200)
bit.save(ProjectPath & "Attachments\图片\" & "TM" & ".jpg")
memoryGraphics.dispose
myGraphics.dispose
bit.dispose

'截取第二个页面
e.Form.Controls("TabControl1").SelectedIndex = 0
Application.Doevents
Dim trv1 = e.Form.Controls("PictureBox2").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-60) '截取的大小
Dim bit1 As New Bitmap(s1.Width, s1.Height , myGraphics1)
Dim memoryGraphics1 As Graphics = Graphics.FromImage(bit1)
memoryGraphics1.CopyFromScreen(point.x+4, point.y+55, 0, 0, s1) '截取的开始位置,坐标(100, 200)
bit1.save(ProjectPath & "Attachments\图片\" & "DA" & ".jpg")
memoryGraphics1.dispose
myGraphics1.dispose
bit1.dispose
msgbox("答案已保存!")

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/27 11:21:00 [显示全部帖子]

……
bit.dispose
    Forms("错题数据").Controls("PictureBox1").ImageFile = ""
    Forms("错题数据").Controls("PictureBox1").ImageFile = ProjectPath & "Attachments\错题\" & Tables("错题数据_table1").Current("编号") & "TM" & ".jpg"
    
    Application.Doevents
    e.Form.Controls("TabControl1").SelectedIndex = 0
    Application.Doevents
    Dim trv1 = e.Form.Controls("WebBrowser2").BaseControl
……

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/27 13:39:00 [显示全部帖子]

我测试没有问题,不行就等待几秒秒后再截第二个

……
bit.dispose
    Forms("错题数据").Controls("PictureBox1").ImageFile = ""
    Forms("错题数据").Controls("PictureBox1").ImageFile = ProjectPath & "Attachments\错题\" & Tables("错题数据_table1").Current("编号") & "TM" & ".jpg"
    Dim sdt As Date = Date.Now
While Date.Now < sdt.AddSeconds(2)
    Application.DoEvents
End While
    e.Form.Controls("TabControl1").SelectedIndex = 0
    Application.Doevents
    Dim trv1 = e.Form.Controls("WebBrowser2").BaseControl
……

 回到顶部