有没有办法强制控制台应用程序以特定的窗口大小运行(使用 Pdcurses)?
我正在尝试用 C++ 编写一个小型 Roguelike 游戏,但遇到了一个问题 - 为了让游戏正确显示,控制台窗口必须有点宽(大约 45 行,115 列) )。通过右键单击菜单栏并设置同名窗口的默认值来更改很容易,但是有没有一种方法可以从代码中自动设置它,这样我就不必要求潜在用户搞乱它?我正在使用 Pdcurses 来处理输出,如果这有帮助的话。
I'm trying my hand at throwing together a minor roguelike in C++, but I've run into a problem - in order to get the game to display correctly, the console window has to be a bit wide (around 45 rows, 115 cols). It's easy enough to change by right clicking on the menu bar and setting the defaults for windows with the same name, but is there a way I could set it automatically from the code so I don't have to ask potential users to mess with that? I'm using Pdcurses to handle output, if that helps at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
IIRC,这个可以在启动游戏的快捷方式中设置,但它不是文本,我不知道使用哪些库或Windows API来修改它。这可能比尝试使用 pdcurses 更简单。
但是,不要忘记 Windows 确实有多个控制台 API。从 MSDN 中的 AllocConsole 开始了解概述,或直接跳至 SetConsoleWindowInfo。
IIRC, this can be set in the shortcut that launches the game, but it's not text and I don't know which libraries or Windows APIs are used to modify it. That may be simpler than trying to use pdcurses.
However, don't forget Windows does have several console APIs. Start at AllocConsole in MSDN for an overview, or skip right to SetConsoleWindowInfo.
这是一个非常老的问题,但无论如何我都会发布我的答案,以防它将来对某人有所帮助。
这就是我在 MS Windows 中使用的:
我在调用
initscr();
之前直接使用它,它的工作方式就像一个魅力。显然,这不是很便携,但如果您在 Windows 上进行开发,它就可以发挥作用。
This is a really old question, but I'll post my answer anyway in case it helps someone in the future.
This is what I use in MS Windows:
I use this directly before my call to
initscr();
, and it works like a charm.This is, obviously, not very portable, but it does the trick if all you're developing on is Windows.
什么操作系统? (因为它是特定于操作系统的)
在 Windows 中 SetConsoleWindowInfo()
What OS? (because it is OS specific)
In Windows SetConsoleWindowInfo()