如何在窗口中缩放屏幕
How get screen scale in windows?
我正在编写一个Windows程序,允许用户在1920 * 1080和3840 * 2160之间切换分辨率,这意味着在FHD和4K之间切换。
我尝试使用"GetSystemMetrics"来获得当前的分辨率。
//Algorithm #1
//Get current resolution and resolution scaling.
xScreenResolution = GetSystemMetrics(SM_CXSCREEN);
yScreenResolution = GetSystemMetrics(SM_CYSCREEN);
cout << "Current Resolution is: " << xScreenResolution << "x" << yScreenResolution << endl;
例如,如果我使用的分辨率为 3840*2160,我希望程序会给我 3840*2160 的分辨率。但是,该程序仅输出1536x864,这是Windows执行重新缩放后的分辨率。
所以我想知道如何像 Windows 100 中的显示设置一样以编程方式获取比例因子(100%、200%、250% 等)。视窗 10 中的显示设置
您的应用程序似乎接收了虚拟化的 DPI 数据。若要接收正确的指标,需要提供适当的应用程序清单,包括高 DPI 支持和系统兼容性条目。请参阅高 DPI。
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>
</windowsSettings>
</application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
要获得缩放,您可以调用GetDpiForMonitor
。
相关文章:
- UE4-如何在给定4个屏幕坐标的情况下缩放纹理或材质
- 计算缩放多边形的比例,得到给定的多边形面积
- QwtPlot具有相等的轴和自动缩放
- 如何在directx/c++中进行平移/缩放操作
- 在Qt中实现无限可缩放的画布
- 是否可以为 QPixmap 派生类嵌入缩放方法?
- 形状对象的旋转和缩放不正确C++
- 如何在 OpenSceneGraph 中缩放/旋转/移动资产
- 如何在OpenGL(GLFW,很高兴)中进行2D缩放?
- 改变或缩放两个正态分布以具有特定的相关系数
- SDL2 调整窗口大小后如何缩放鼠标坐标?
- 如何在OpenGL中正确旋转和缩放对象?
- 仅当类型为 std::complex 时,才进行缩放
- 将 VS Code 用于跨平台可缩放C++项目
- 根据帧速率缩放/缩小数字
- 在 c++ 中缩放浮点值
- 如何防止 DirectX C++程序的拉伸/缩放
- C++ WinRT - 如何动态缩放可写位图以匹配当前屏幕分辨率
- 如何在 Windows 10 上检测辅助监视器的本机屏幕分辨率或缩放因子
- 如何在窗口中缩放屏幕