简体   繁体   English

如何在控制台应用程序的Windows窗体应用程序中指定最后一个窗体?

[英]How to specify last form in Windows forms application in Console Application?

    static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        Thread thread = new Thread(new ThreadStart(Debug));
        thread.Start();
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new MainForm());
    }

    static void Debug()
    {
        Console.WriteLine(Console.ReadLine());
    }

I have something like that. 我有类似的东西。 It launchs a console and a windows form. 它启动控制台和Windows窗体。 What I want to do is Hide or close the console application without terminating the whole application and show it later by pressing a button or something like that from form. 我想做的是隐藏或关闭控制台应用程序,而不终止整个应用程序,稍后再通过按下按钮或类似表单中的按钮来显示它。 How can I prevent the application from closing? 如何防止应用程序关闭?

Can't we just fit up a console in windows form? 我们不能只安装Windows形式的控制台吗? My real problem is I'm writting an windows forms application. 我真正的问题是我正在编写Windows窗体应用程序。 Also I want a window (console window) that will execute and test some functions on windows forms. 我也想要一个将在Windows窗体上执行和测试某些功能的窗口(控制台窗口)。

Something similar answered here: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/ea8b0fd5-a660-46f9-9dcb-d525cc22dcbd 类似的答案在这里: http : //social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/ea8b0fd5-a660-46f9-9dcb-d525cc22dcbd

Basically, seems like you need to call some windows API functions to show/hide the console. 基本上,似乎您需要调用一些Windows API函数来显示/隐藏控制台。

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

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