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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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:
int err = system("mode con lines=45 cols=115");
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.
回答3:
What OS? (because it is OS specific)
In Windows SetConsoleWindowInfo()
回答4:
/* Resize the terminal to something larger than the physical screen */
resize_term(2000, 2000);
/* Get the largest physical screen dimensions */
getmaxyx(_window, _rows, _cols);
/* Resize so it fits */
resize_term(_rows - 1, _cols - 1);
/* Get the screen dimensions that fit */
getmaxyx(_window, _rows, _cols);