3

在我的控制台应用程序中创建一个 from 后,我想隐藏我的控制台。然后在关闭表单后再次显示它:) 或者当我想要的某个地方......

Console.Hide???
Application.Run(nForm());
Console.Show???
4

1 回答 1

7

我认为您需要深入研究 FindWindow 和 ShowWindow API 调用。例如:

    [DllImport("user32.dll")]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);


    [DllImport("user32.dll")]
    public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

    static void Main(string[] args)
    {
        Console.Title = "ConsoleApplication1";

        IntPtr h=FindWindow(null, "ConsoleApplication1");

        ShowWindow(h, 0); // 0 = hide

        Form f = new Form();

        f.ShowDialog();

        ShowWindow(h, 1); // 1 = show

    }
于 2010-01-29T06:49:18.697 回答