我正在编写一个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'。任何人都可以提供一些见解,为什么会这样?非常感谢!
答案 0 :(得分:1)
您忘了查看dmPossibleMode.dmFields
DM_DISPLAYFIXEDOUTPUT
。如果未设置该位,则dmPossibleMode.dmDisplayFixedOutput
处使用的值尚未初始化,因此无需进行检查。
如果未设置DM_DISPLAYFIXEDOUTPUT,则此成员必须为零。
来自http://msdn.microsoft.com/en-us/library/windows/desktop/dd183565%28v=vs.85%29.aspx
如果我没记错,这些“拉伸”值仅在笔记本电脑屏幕上有意义,但这可能是错误的,不要以它为基础。