简体   繁体   中英

Strange SetConsoleScreenBufferInfoEx behavior

If i create a C# console application which sets the console Buffer/Window Width and Height (using Console.*-Methods) to 80x25 (or any other specific size) the console-window has no scrollbars.

When i use GetConsoleScreenBufferInfoEx to read the consolebuffer-settings it reports a window.Right and window.Bottom of 79x24. If i write the read CONSOLE_SCREEN_BUFFER_INFO_EX back the window will get scrollbars.

Question: Are there any C#/.NET-framework methods interfering or is this standard behavior?

I've seen examplecode for C on the internet which is always doing window.Right++ and window.Bottom++.

For the first question, I think you're getting scroll bars because your window is actually getting smaller. It's a bug.

See 35901572 and note, for reference that the examples on PInvoke always fix the size.

Try adding a couple lines after you call GetConsoleScreenBufferInfoEx:

GetConsoleScreenBufferInfoEx(handle, ref currentScreen);
++currentScreen.srWindowBottom;
++currentScreen.srWindowRight;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM