如何删除控制台窗口中的滚动条 C++
我一直在检查一些用 C 编写的 Rogue 类游戏(Larn、Rogue 等)和 C++,我注意到它们的控制台窗口右侧没有滚动条。
我怎样才能完成同样的功能?
I have been checking out some Rogue like games (Larn, Rogue, etc) that are written in C and C++, and I have noticed that they do not have the scrollbars to the right of the console window.
How can I accomplish this same feature?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
要删除滚动条,只需将屏幕缓冲区高度设置为与窗口高度相同的大小:
To remove the scrollbar, simply set the screen buffer height to be the same size as the height of the window:
您需要使控制台屏幕缓冲区的大小与控制台窗口的大小相同。使用 GetConsoleScreenBufferInfo、srWindow 成员获取窗口大小。使用 SetConsoleScreenBufferSize() 设置缓冲区大小。
You need to make the console screen buffer the same size as the console window. Get the window size with GetConsoleScreenBufferInfo, srWindow member. Set the buffer size with SetConsoleScreenBufferSize().
使用
#include
,您可以简单地执行指定使用不同参数隐藏哪个滚动条。
Using
#include <winuser.h>
, you can simply doYou can specify which scroll bar to hide using different parameters.
要从控制台中删除滚动条,我们可以使控制台屏幕缓冲区的大小与控制台窗口的大小相同。这可以按如下方式完成:
To remove scrollbars from the console, we can make the console screen buffer the same size as the console window. This can be done as follows: