2010-01-29 55 views

回答

8

我认为你需要钻研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 

    } 
+0

谢谢:) 非常有趣的方法 – Cynede 2010-01-29 07:14:59

+0

很高兴提供帮助。当然,这使得它看起来像一个普通的Windows窗体应用程序,所以你最好使用Windows窗体,除非你真的需要控制台窗口。 – Ash 2010-01-29 07:21:34

+0

赢得应用程序在Nemerle当前版本> _ < – Cynede 2010-01-29 07:39:57