SetConsoleScreenBufferInfoEx ... bug?

问题描述 投票:4回答:1

每次我运行此代码(在Win7上)时,控制台在两个方向上都会减少1个字符。

int wmain( INT argc, WCHAR **argv )  
{  
    CONSOLE_SCREEN_BUFFER_INFOEX csbi;  
    csbi.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);  
    GetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);  
    wprintf(L"Window: %u x %u\n", csbi.srWindow.Right - csbi.srWindow.Left + 1, csbi.srWindow.Bottom - csbi.srWindow.Top + 1);  
    SetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);  
    return 0;  
}

我怀疑这是预期的行为。有记录吗?在较新版本的Windows中它是否更好?这是一个运行它几次的剪辑。

p:\ test \ release> test.exe 窗口:99 x 41

p:\ test \ release> test.exe 窗口:98 x 40

p:\ test \ release> test.exe 窗口:97 x 39

windows console-application
1个回答
1
投票

Windows控制台API中的长期“无法解决”错误。你只需要做其他人做的事情,并增加窗口.Bottom和window.Right阅读后。

GetConsoleScreenBufferInfoEx(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)
++csbi.srWindowBottom;
++csbi.srWindowRight;
© www.soinside.com 2019 - 2024. All rights reserved.