操作系统:Windows 7 64位
两个显示器,一个横屏,一个竖屏。横屏是主显示器。
我正在尝试使用SetConsoleWindowInfo来调整控制台的大小,但如果我试图将其调整为适合于竖屏显示器但不适合于横屏(主要)显示器的大小,则该函数会返回失败,即使控制台实际上位于竖屏上。
我知道Windows使用屏幕大小作为控制台窗口尺寸的上限。然而,它仅使用主显示器的屏幕大小。是否有任何方法可以指定要使用哪个屏幕的尺寸,或者更好的是,将其设置为使用组合桌面区域作为最大尺寸?
操作系统:Windows 7 64位
两个显示器,一个横屏,一个竖屏。横屏是主显示器。
我正在尝试使用SetConsoleWindowInfo来调整控制台的大小,但如果我试图将其调整为适合于竖屏显示器但不适合于横屏(主要)显示器的大小,则该函数会返回失败,即使控制台实际上位于竖屏上。
我知道Windows使用屏幕大小作为控制台窗口尺寸的上限。然而,它仅使用主显示器的屏幕大小。是否有任何方法可以指定要使用哪个屏幕的尺寸,或者更好的是,将其设置为使用组合桌面区域作为最大尺寸?
#include "windows.h"
#include <conio.h>
int _tmain(int argc, _TCHAR* argv[])
{
bool hasSecondary = false;
POINT secondaryPosition;
POINT secondarySize;
POINT primarySize;
{
DISPLAY_DEVICE displayDevice;
displayDevice.cb = sizeof(DISPLAY_DEVICE);
DEVMODE deviceMode;
ZeroMemory(&deviceMode, sizeof(DEVMODE));
deviceMode.dmSize = sizeof(DEVMODE);
int i = 0;
while(::EnumDisplayDevices(NULL, i++, &displayDevice, 0))
{
if(displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP &&
!(displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))
{
if(EnumDisplaySettingsEx(displayDevice.DeviceName, ENUM_CURRENT_SETTINGS, &deviceMode, 0) == FALSE)
EnumDisplaySettingsEx(displayDevice.DeviceName, ENUM_REGISTRY_SETTINGS, &deviceMode, 0);
if(deviceMode.dmPosition.x != 0 || deviceMode.dmPosition.y != 0)
{
hasSecondary = true;
secondaryPosition.x = deviceMode.dmPosition.x;
secondaryPosition.y = deviceMode.dmPosition.y;
secondarySize.x = deviceMode.dmPelsWidth;
secondarySize.y = deviceMode.dmPelsHeight;
}
else
{
primarySize.x = deviceMode.dmPelsWidth;
primarySize.y = deviceMode.dmPelsHeight;
}
}
}
}
MoveWindow(GetConsoleWindow(),
secondaryPosition.x, secondaryPosition.y,
secondarySize.x, secondarySize.y,
TRUE);
_getch();
return 0;
}