小编Jim*_*Jim的帖子

为什么“GetDeviceCaps”函数总是返回屏幕尺寸的一半?

我一直在尝试使用 <Windows.h> 的函数获取屏幕尺寸GetDeviceCaps(GetDC(NULL), HORZRES),但每当我运行代码时,它总是返回屏幕分辨率的一半。

有谁知道为什么我的电脑会发生这种情况?它在大多数其他显示器上运行良好。

我的屏幕分辨率是 (2736x1824) (surface pro)。

#include <Windows.h>
#include <iostream>
int main()
{
    HDC display = GetDC(NULL);
    const int x = GetDeviceCaps(display, HORZRES), y = GetDeviceCaps(display, VERTRES); //returns (1368, 912)
    std::cout << x << ", " << y << "\n";
    system("pause");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ winapi c++20

2
推荐指数
1
解决办法
950
查看次数

标签 统计

c++ ×1

c++20 ×1

winapi ×1