Pregunta

Quiero ocultar mi consola después de la creación de una aplicación de consola en mi. Y luego mostrar de nuevo después de cerrar forma :) o en algún lugar cuando quiero ...

Console.Hide???
Application.Run(nForm());
Console.Show???
¿Fue útil?

Solución

creo que necesita para ahondar en las llamadas a la API FindWindow y ShowWindow. Por ejemplo:

    [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

    }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top