替代的方法来最大化控制台窗口 - C# [英] Alternative method to maximising the Console Window - C#

查看:127
本文介绍了替代的方法来最大化控制台窗口 - C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个原型一块的功能,我将实现在一个应用程序,特别是我从收集的数据显示在控制台窗口,但不幸的是一些线路的跨度比控制台的默认宽度更宽窗口。

I'm creating a prototype for a piece of functionality that I will be implementing in an application, specifically I am displaying data from a collection to the console window but unfortunately some of the lines span wider than the default width of the console window.

我已经做了一点<一href="http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/0b374f73-5604-48ee-a720-53bb5b19467b/"相对=nofollow>挖掘和发现,要增加窗口的宽度,唯一的办法就是挖成的Kernel32.dll并手工完成。

I've done a bit of digging and found that the only way to increase the width of the window is to dig into the Kernel32.dll and do it manually.

那样优雅PInvoke的是,没有一个短的方式存在,增加了宽度,例如(Console.Width = 300),或正在使用的Kernel32.dll的唯一途径。

As elegant as pInvoke is, does a "shorter" way exist to increase the width e.g. (Console.Width = 300) or is using the Kernel32.dll the only way.

谢谢!

推荐答案

无需编程。创建您的桌面上的程序的快捷方式。用鼠标右键单击它,属性,布局选项卡。调整屏幕缓冲区和窗口大小的Width属性。

No programming is required. Create a shortcut to your program on the desktop. Right-click it, Properties, Layout tab. Adjust the Width property of the screen buffer and window size.

但你可以做到这一点编程也一样,你发现那些Windows API函数都是由控制台类包装为好。例如:

But you can do it programmatically too, those Windows API functions you found are wrapped by the Console class as well. For example:

    static void Main(string[] args) {
        Console.BufferWidth = 100;
        Console.SetWindowSize(Console.BufferWidth, 25);
        Console.ReadLine();
    }

这篇关于替代的方法来最大化控制台窗口 - C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆