如何将显示器设置在垂直位置?
下面的
代码可以设置分辨率和刷新率,但我无法弄清楚如何将两个显示器设置在垂直位置。
我尝试过dm.dmDisplayOrientation但没有奏效。 在将显示设置为垂直对齐时还有其他配置。
使用Windows显示设置进行设置时的垂直对齐工作。
int main(int argc, char* argv[])
{
SetDisplay("DELL S2240L(Analog)",0,0,1600,900,60,false);
SetDisplay("DELL S2240L(Hdmi)",0,900,1600,1800,60,true);
return 0;
}
bool SetDisplay(std::string monitorname,int pox,int poy,int w,int h,int r,bool parent)
{
DWORD iDevNum(0);
DISPLAY_DEVICE dd;
dd.cb = sizeof(dd);
while ( EnumDisplayDevices(0, iDevNum, &dd, 0) )
{
if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
{
DISPLAY_DEVICE dd2;
dd2.cb = sizeof(dd2);
EnumDisplayDevices(dd.DeviceName, 0, &dd2, 0);
if(monitorname.compare(dd2.DeviceString)==0)
{
DEVMODE dm;
ZeroMemory(&dm ,sizeof(dm));
dm.dmSize = sizeof(DEVMODE);
if (!EnumDisplaySettings(dd.DeviceName, ENUM_CURRENT_SETTINGS, &dm))
{
std::cout <<"EnumDisplaySettings failed:%d\n"<< GetLastError()<< std::endl;
return FALSE;
}
dm.dmPelsWidth = w;
dm.dmPelsHeight = h;
POINTL po;
po.x=pox;
po.y=poy;
dm.dmPosition = po;
dm.dmDisplayFrequency = r;
dm.dmFields = (DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY | DM_POSITION );//| DM_DISPLAYORIENTATION );
if (ChangeDisplaySettings(&dm, CDS_TEST) !=DISP_CHANGE_SUCCESSFUL)
{
std::cout << "Illegal graphics mode: %d\n"<< GetLastError()<< std::endl;
}
else
{
std::cout << "can be applied on "<< dd.DeviceString<< std::endl;
}
std::cout << "try applied on "<< dm.dmDeviceName<< std::endl;
ChangeDisplaySettingsEx(dd.DeviceName, &dm, NULL, CDS_FULLSCREEN| CDS_SET_PRIMARY , NULL);
}
else
{
std::cout <<" no "<<monitorname.c_str()<<" =="<<dd2.DeviceString << std::endl;
}
}
++iDevNum;
}
}
对齐前的屏幕
对齐后的屏幕