CodeGo.net>有没有办法做一个固定的(高度/宽度)控制台? [英] c# - Is there a way to make a fixed (height/width) console?

查看:49
本文介绍了CodeGo.net>有没有办法做一个固定的(高度/宽度)控制台?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搞怪Microsoft Visual Studio 2013,并制作了一个控制台应用程序,但我想知道是否有一种方法可以为其设置固定的大小(高度/宽度),这意味着调整大小了吗?如果有人知道这是否可能,请您能帮助我,我们将不胜感激.谢谢!

I've been messing around in microsoft visual studio 2013, and I made a console application, but I was wonder if there was a way to make a fixed size for it (height/width), meaning it can't be resized whatsoever? If anyone knows if this is possible, I'd appreciate if you can help me. Thank you!

推荐答案

为达到此效果,您需要使用一些C ++类库:

In order to achieve this effect, you need to use some C++ class library:

const int MF_BYCOMMAND = 0x00000000;
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;
const int SC_SIZE = 0xF000;

[DllImport("user32.dll")]
public static extern int DeleteMenu(IntPtr hMenu, int nPosition, int wFlags);

[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);

[DllImport("kernel32.dll", ExactSpelling = true)]
private static extern IntPtr GetConsoleWindow();

static void Main(string[] args)
{
    Console.WindowHeight = 25;
    Console.WindowWidth = 80;

    DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_MINIMIZE, MF_BYCOMMAND);
    DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_MAXIMIZE, MF_BYCOMMAND);
    DeleteMenu(GetSystemMenu(GetConsoleWindow(), false), SC_SIZE, MF_BYCOMMAND);

    Console.WriteLine("Yes, its fixed!");
    Console.ReadLine();
}

希望这很有用.

这篇关于CodeGo.net>有没有办法做一个固定的(高度/宽度)控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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