本文介绍了如何在控制台应用程序中创建表后隐藏控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的控制台应用程序创建后隐藏我的控制台。然后关闭表:)或地方时,我想...
后,再次显示它 Console.Hide ???
Application.Run(nForm());
Console.Show ???
解决方案
我认为你需要钻研的FindWindow和的ShowWindow API调用。例如:
[的DllImport(user32.dll中)
公共静态外部的IntPtr的FindWindow(字符串lpClassName,串lpWindowName);
[的DllImport(user32.dll中)
公共静态的extern BOOL的ShowWindow(IntPtr的的HWND,INT的nCmdShow);
静态无效的主要(字串[] args)
{
Console.Title =ConsoleApplication1;
IntPtr的H =的FindWindow(NULL,ConsoleApplication1);
的ShowWindow(小时,0); // 0 =隐藏
FORM F =新表();
f.ShowDialog();
的ShowWindow(H,1); // 1 =秀
}
I want to hide my console after creating a from in my console application.And then show it again after closing form :) or somewhere when I want ...
Console.Hide???
Application.Run(nForm());
Console.Show???
解决方案
I think you'll need to delve into the FindWindow and ShowWindow API calls. For example:
[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
}
这篇关于如何在控制台应用程序中创建表后隐藏控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!