How to hide the console after creating the form in the console application

I want to hide my console after creating the application from my console application. And then show it again after closing the form :) or somewhere, when I want ...

Console.Hide??? Application.Run(nForm()); Console.Show??? 
+3
source share
1 answer

I think you need to delve deeper into the FindWindow and ShowWindow API calls. For instance:

  [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 } 
+8
source

All Articles