捕获表单的代码在Windows 10中不起作用 [英] Code for capturing form does not work in Windows 10

查看:149
本文介绍了捕获表单的代码在Windows 10中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用针对.Net Framework 4.0的VS2010。 我多年来一直使用以下代码来捕获我的表单。我刚刚发现它在Windows 10机器上不起作用。 在Windows 7上运行良好并且已有多年。 对于Win 10需要更改的内容有任何想法
? 调用CaptureScreen()后,调用例程将打印memoryImage或将其放在剪贴板上。 在Win 10上,我获得了表单的一部分和桌面的一部分。 感谢任何帮助,我可以
得到这个。

私有memoryImage as Bitmap 
Private Sub CaptureScreen()
Dim myGraphics As Graphics = Me.CreateGraphics()
Dim s As Size = Me.Size

My.Application.DoEvents()'确保隐藏下拉b4捕获图像

memoryImage =新位图(s.Width,s.Height,myGraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
memoryGraphics.CopyFromScreen(Me.Location.X,Me.Location .Y,0,0,s)
myGraphics.Dispose()
memoryGraphics.Dispose()
End Sub




Terry

解决方案

TerryLa,


在Windows 10和VS2017 .Net 4.6中没有问题(和4.0我尝试了额外的)所以我认为你的问题在代码的其他地方。


<顺便说一句,在VB论坛上最近有些人谁是非常擅长的图形,在你的情况下,我会在下次访问该论坛时提出这类问题。


http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral





I am using VS2010 targeting .Net Framework 4.0.  I have been using the following code to capture my form for years. I just discovered that it does not work on Windows 10 machines.  Works fine on Windows 7 and has for years.  Have any idea on what needs to change for Win 10?  After CaptureScreen() is called, the calling routine either prints memoryImage or places it on the clipboard.  On Win 10, I get a portion of the form and a portion of my desktop.  Appreciate any help I can get on this.

Private memoryImage as Bitmap   
 Private Sub CaptureScreen()
        Dim myGraphics As Graphics = Me.CreateGraphics()
        Dim s As Size = Me.Size

        My.Application.DoEvents()   ' ensure drop downs are hidden b4 capturing image

        memoryImage = New Bitmap(s.Width, s.Height, myGraphics)
        Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
        memoryGraphics.CopyFromScreen(Me.Location.X, Me.Location.Y, 0, 0, s)
        myGraphics.Dispose()
        memoryGraphics.Dispose()
    End Sub


Terry

解决方案

TerryLa,

No problem in Windows 10 and VS2017 .Net 4.6 (and 4.0 I tried it extra) so I think your problem is somewhere else in your code.

By the way, in the VB forums are lately some guys who are very good with graphics, In your case I would visit that forum next time for this kind of questions.

http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral


这篇关于捕获表单的代码在Windows 10中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆