Windows10中的Delphi桌面截图,GetDeviceCaps问题
发布时间:2020-12-14 05:45:03 所属栏目:Windows 来源:网络整理
导读:如何在 Windows10中获取正确的屏幕尺寸以截取屏幕截图?它似乎得到不正确的值(可能是DPI问题?) 即 // screenshotb := TBitmap.Create;DC := GetDC(GetDesktopWindow);try b.Width := GetDeviceCaps (DC,HORZRES) ; b.Height := GetDeviceCaps (DC,VERTRES)
如何在
Windows10中获取正确的屏幕尺寸以截取屏幕截图?它似乎得到不正确的值(可能是DPI问题?)
即 // screenshot b := TBitmap.Create; DC := GetDC(GetDesktopWindow); try b.Width := GetDeviceCaps (DC,HORZRES) ; b.Height := GetDeviceCaps (DC,VERTRES) ; BitBlt(b.Canvas.Handle,b.Width,b.Height,DC,SRCCOPY) ; finally ReleaseDC (GetDesktopWindow,DC) ; end; 在4K屏幕上只会捕获左上角的一小部分. 解决方法
您需要使应用程序完全具有高DPI感知能力,才能获得正确的屏幕快照值.
您可以通过在应用程序清单中添加以下部分来实现 <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true/PM</dpiAware> </asmv3:windowsSettings> </asmv3:application> Windows 10自定义清单的完整示例 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> <!-- Windows 10 --> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> <!-- Windows 8.1 --> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> <!-- Windows 8 --> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <!-- Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <!-- Windows Vista --> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> </application> </compatibility> <assemblyIdentity type="win32" name="MyApplication" version="1.0.0.0" processorArchitecture="*"/> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/> </dependentAssembly> </dependency> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true/PM</dpiAware> </asmv3:windowsSettings> </asmv3:application> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> </assembly> 注意:Windows 10引入了Per-monitor DPI感知.上面的清单将这种意识转化为真实/ PM值(PM – Per Monitor). 由于Delphi在西雅图引入了对Per-Monitor DPI的支持,因此使用旧版本编译的应用程序无法在Windows 10上为每个监视器设置不同DPI设置的多监视器设置中正确扩展.根据应用程序和用户群的用途,您可以要么生活在这样的行为,要么你必须升级到最新的Delphi(同样重要的是要注意这是新功能,它确实有一些错误可能与你的情况有关或不相关) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- .net – ScrollViewer中的ListBox
- Windows服务实现IDisposable – 这是不好的做法?
- active-directory – GPO为每台计算机设置壁纸而不是每个用
- pthreads-win32在各种Windows编译器上的可移植性
- 以最快的方式检查安装了哪个版本的Windows Installer?
- windows-server-2003 – 为什么Server 2003没有系统还原?
- windows – 线程ID与线程句柄
- href – Microsoft Lync – 使用来自网页的消息打开IM窗口
- windows – 我什么时候应该在位图上调用DeleteObject()
- windows-phone-7 – 如何处理HTTP 412(前提条件失败) – 设