简体   繁体   English

在应用程序启动时设置控制台窗口的特定大小

[英]Setting a console window specific size at application launch

I'm using windows 10 and the console is being created in visual studio 2015. It is being created simply as a win32 console application in c plus plus. 我正在使用Windows 10,并且控制台是在Visual Studio 2015中创建的。它只是作为c plus plus中的win32控制台应用程序创建的。

I created a videoMemory simulator for a console application in c++. 我为c ++中的控制台应用程序创建了videoMemory模拟器。

class VideoSim
{
private:
char video[MAX_ROWS * MAX_COLS]; // row is 29, columns  is 80
int currentRow;
int currentColumn;

I display a memory block in the console window that displays 29 rows across and 80 columns down holding 2,320 different locations that I can print out. 我在控制台窗口中显示一个内存块,该内存块显示29行,向下80列,其中包含我可以打印的2320个不同位置。 This application will ask me a question create a little image next to my answer. 此应用程序将问我一个问题,在我的答案旁边创建一个小图像。

When I run this application, my console window stretches further then 80 columns across. 当我运行此应用程序时,控制台窗口会延伸得更远,然后跨越80列。 How can I have it defaulted so the console is at a set size, therefor the space I see can only technically all be written to. 如何将其默认设置为使控制台处于固定大小,因此,我看到的空间在技术上只能全部写入。

I am not familiar with any console specific functions, if someone could kindly just point me in the right direction. 如果有人可以向我指出正确的方向,我对任何控制台特定的功能都不熟悉。

as far as printing out to my video sim, I set the cursor location 至于打印到我的视频模拟卡,我设置光标位置

void VideoSim::SetCursorPosition(int r, int c)
{
    if (c > MAX_COLS || r > MAX_ROWS)
{
    printf("OUTSIDE OF RANGE                  --\n");
    printf("Max column = 40, Max row = 10     --\n\n");
}
currentColumn = c;
currentRow = r;
}

then I print at that location, hence always staying within the virtual video memory range. 然后在该位置打印,因此始终处于虚拟视频内存范围内。

You're actually going about it the wrong way. 您实际上是在以错误的方式进行操作。

While your application technically could modify the console, it should not . 从技术上讲,您的应用程序可以修改控制台, 但不能 It is the user's prerogative to do that. 这样做是用户的特权。 So... as the user, you should: 因此...作为用户,您应该:

Create a shortcut that starts your program with the desired console. 创建一个快捷方式,使用所需的控制台启动程序。

This is actually rather easy. 这实际上很容易。 Right-click your app and modify the startup parameters, including console size and, if you wish, position. 右键单击您的应用程序,然后修改启动参数,包括控制台大小以及(如果需要)位置。

Thereafter, link everything that triggers your application to the shortcut , which will set-up your console window and start your application. 然后,将触发您的应用程序的所有内容链接到快捷方式 ,该快捷方式将设置您的控制台窗口并启动您的应用程序。

Hope this helps. 希望这可以帮助。

您可以使用Window的控制台窗口API来调整窗口的大小,但是,最简单的方法是仅使用带有mode con ...命令的C ++库system调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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