zoukankan      html  css  js  c++  java
  • WinForm 程序启动时不显示主窗体

    WinForm程序启动时不显示主窗体的实现方法,试来试去还是这个方法比较好:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Windows.Forms;
     4 
     5 namespace winAppTest1
     6 {
     7     static class Program
     8     {
     9         /// <summary>
    10         /// The main entry point for the application.
    11         /// </summary>
    12         [STAThread]
    13         static void Main()
    14         {
    15             Application.EnableVisualStyles();
    16             Application.SetCompatibleTextRenderingDefault(false);
    17             //Application.Run(new Form1());
    18 
    19             Application.Run(new AppContext(new Form1()));
    20         }
    21     }
    22 
    23 
    24     internal class AppContext : ApplicationContext
    25     {
    26         private Form mainForm;
    27 
    28         public AppContext(Form mainForm)
    29         {
    30             this.mainForm = mainForm;
    31             this.mainForm.Closed += new EventHandler(mainForm_Closed);
    32         }
    33 
    34         // 主窗体被关闭时,退出应用程序
    35         void mainForm_Closed(object sender, EventArgs e)
    36         {
    37             Application.Exit();
    38         }
    39     }
    40 }

    本文地址:http://www.cnblogs.com/anjou/archive/2006/04/18/378022.html

  • 相关阅读:
    Google's Innovation Factory (and how testing adapts)
    虎年拜年帖
    [ZZ]让测试也敏捷起来
    Selenimu做爬虫续
    OKR的解说
    春秋航空的机上店铺
    免费TK域名试用
    快速排序_C语言实现
    第一篇博客
    C、C++代码格式优化软件献给编程爱好者
  • 原文地址:https://www.cnblogs.com/anjou/p/378022.html
Copyright © 2011-2022 走看看