有没有一种方法可以强制控制台应用程序以一定的窗口大小运行(使用Pdcurses)?

编程入门 行业动态 更新时间:2024-10-06 08:35:34
本文介绍了有没有一种方法可以强制控制台应用程序以一定的窗口大小运行(使用Pdcurses)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试用C ++拼凑一个小小的roguelike,但是我遇到了一个问题-为了使游戏能够正确显示,控制台窗口必须有点宽(大约45行) ,115列).右键单击菜单栏并为具有相同名称的Windows设置默认值,更改起来很容易,但是有一种方法可以自动从代码中进行设置,因此我不必让潜在用户弄乱它?我正在使用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.

推荐答案

这是一个非常老的问题,但是我还是会贴出答案,以防将来对某人有所帮助. 这是我在MS 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:

int err = system("mode con lines=45 cols=115");

我直接在调用initscr();之前使用它,它的工作原理就像是一种魅力. 显然,这不是很可移植,但是如果您使用的是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.

更多推荐

有没有一种方法可以强制控制台应用程序以一定的窗口大小运行(使用Pdcurses)?

本文发布于:2023-11-03 04:49:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554277.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制台   应用程序   大小   窗口   方法

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!