【问题标题】:No Scaling/Fixed Output Resolution support?不支持缩放/固定输出分辨率?
【发布时间】:2014-04-03 08:51:53
【问题描述】:

我正在编写一个 Win32 C++ 程序来更改各种机器的屏幕分辨率和缩放模式。我正在运行 Windows 7,但针对的是 Windows XP。该程序可以在我的 Windows 7 笔记本电脑上运行,在枚举兼容的显示模式方面:

if (listModes)
{
    DEVMODE dmPossibleMode = { 0 };
    ZeroMemory(&dmPossibleMode, sizeof(dmPossibleMode));
    dmPossibleMode.dmSize = sizeof(dmPossibleMode);

    cout << "Key: BD = Bit density/Bits per pixel, SM = Scale mode" << endl;
    cout << "+-----+-----------+-------+----+----+" << endl;
    cout << "|  ID |   Dims    | Freq. | BD | SM |" << endl;
    cout << "+-----+-----------+-------+----+----+" << endl;
    for(int iModeNum = 0; EnumDisplaySettings(dd.DeviceName, iModeNum, &dmPossibleMode) != 0; iModeNum++)
    {
        ostringstream resString; resString << dmPossibleMode.dmPelsWidth << "x" << dmPossibleMode.dmPelsHeight;
        ostringstream freqString; freqString << dmPossibleMode.dmDisplayFrequency << "Hz";
        ostringstream bbpString; bbpString << dmPossibleMode.dmBitsPerPel;
        ostringstream scaleString; scaleString << dmPossibleMode.dmDisplayFixedOutput;
        cout << "|" << setw(4) << iModeNum << " ";
        cout << "|" << setw(10) << resString.str() << " ";
        cout << "|" << setw(6) << freqString.str() << " ";
        cout << "|" << setw(3) << bbpString.str() << " ";
        cout << "|" << setw(3) << scaleString.str() << " |" << endl;
    }
    cout << "+-----+-----------+-------+----+----+" << endl;
}

给我:

+-----+-----------+-------+----+----+
|  ID |   Dims    | Freq. | BD | SM |
+-----+-----------+-------+----+----+
|   0 |   640x480 |  59Hz |  8 |  0 |
|   1 |   640x480 |  60Hz |  8 |  0 |
|   2 |   640x480 |  60Hz |  8 |  2 |
|   3 |   640x480 |  60Hz |  8 |  1 |
|   4 |   640x480 |  73Hz |  8 |  0 |
|   5 |   640x480 |  75Hz |  8 |  0 |
|   6 |   640x480 |  75Hz |  8 |  2 |
|   7 |   640x480 |  75Hz |  8 |  1 |
|   8 |   640x480 |  59Hz | 16 |  0 |
|   9 |   640x480 |  60Hz | 16 |  0 |
|  10 |   640x480 |  60Hz | 16 |  2 |
[ etc.                              ]

但是在 Windows XP 桌面上,输出是这样的:

+-----+-----------+-------+----+----+
|  ID |   Dims    | Freq. | BD | SM |
+-----+-----------+-------+----+----+
|   0 |   640x480 |  59Hz |  8 |  0 |
|   1 |   640x480 |  60Hz |  8 |  0 |
|   2 |   640x480 |  60Hz |  8 |  0 |
|   3 |   640x480 |  60Hz |  8 |  0 |
|   4 |   640x480 |  73Hz |  8 |  0 |
|   5 |   640x480 |  75Hz |  8 |  0 |
|   6 |   640x480 |  75Hz |  8 |  0 |
|   7 |   640x480 |  75Hz |  8 |  0 |
|   8 |   640x480 |  59Hz | 16 |  0 |
|   9 |   640x480 |  60Hz | 16 |  0 |
|  10 |   640x480 |  60Hz | 16 |  0 |
[ etc.                              ]

即缩放模式都说“0”。谁能提供一些关于为什么会这样的见解?非常感谢!

【问题讨论】:

  • EnumDisplaySettings() 的 MSDN 库文章确实承诺该字段将具有值,您必须检查 dmFields。在 Vista 中,视频设备驱动程序规范进行了重大修订,使用了一种称为 WDDM 的新驱动程序模型。这可能与它有关。
  • 确实如此,难道不可能从 Windows API 中确定支持的缩放模式吗?

标签: c++ visual-c++


【解决方案1】:

您忘记检查 dmPossibleMode.dmFieldsDM_DISPLAYFIXEDOUTPUT。如果没有设置该位,则您在dmPossibleMode.dmDisplayFixedOutput 使用的值尚未初始化,因此检查它是没有价值的。

如果未设置 DM_DISPLAYFIXEDOUTPUT,则此成员必须为零。

来自http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565%28v=vs.85%29.aspx

如果我没记错的话,这些“拉伸”值仅在笔记本电脑屏幕上有意义,但这可能是错误的,不要以此为基础。

【讨论】:

  • 只有在将 DEVMODE 结构传递给 apply 设置时才需要设置。我在循环中使用EnumDisplaySettings 来检索所有支持的模式属性。我确实注意到它说它只填充dmBitsPerPeldmPelsWidthdmPelsHeightdmDisplayFlagsdmDisplayFrequency - 在这种情况下,我现在的问题是如何枚举支持的缩放模式..?我现在在别处问过这个问题。
猜你喜欢
  • 2012-09-12
  • 2021-06-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-18
  • 1970-01-01
  • 1970-01-01
  • 2011-04-07
相关资源
最近更新 更多