【发布时间】:2010-01-29 06:41:37
【问题描述】:
我想在我的控制台应用程序中创建一个 from 后隐藏我的控制台。 然后在关闭表单后再次显示它:) 或我想要的某个地方...
Console.Hide???
Application.Run(nForm());
Console.Show???
【问题讨论】:
我想在我的控制台应用程序中创建一个 from 后隐藏我的控制台。 然后在关闭表单后再次显示它:) 或我想要的某个地方...
Console.Hide???
Application.Run(nForm());
Console.Show???
【问题讨论】:
我认为您需要深入研究 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
}
【讨论】:
GetConsoleWindow 而不是FindWindow。 msdn.microsoft.com/en-us/library/ms683175(VS.85).aspx