闪屏窗口

你可以做一个
闪屏窗口
像 Microsoft Visual Studio .NET 2003
具体代码片断
[STAThread]
public static void Main()
{
 _MainForm= new MainForm();
 //主窗口传递给闪屏 窗口
 FlashScreenFrm fs = new FlashScreenFrm(_MainForm);
 //闪屏模式显示
 if (fs.ShowDialog()==DialogResult.Cancel)
 {
  System.Environment.Exit(1);
 }
 //完成后销毁
 fs.Dispose();

 try
 {
  //启动主窗口
  Application.Run(_MainForm);
 }
 catch(Exception ex)
 {
  MessageBox.Show(ex.ToString());
  System.Environment.Exit(1);
 }
 finally
 {
  
 }
}

//闪屏窗口
///窗口为平板样式
public class FlashScreenFrm : System.Windows.Forms.Form
{
 //显示消息
 private System.Windows.Forms.Label label1;
 
 private System.ComponentModel.IContainer components=null;
 //时间控件
 private System.Windows.Forms.Timer timer1;
 //放置图形
 private System.Windows.Forms.PictureBox pictureBox1;
 MainForm _mForm;
 //构造1
 public FlashScreenFrm()
 {
  InitializeComponent();
 }
 //构造2
 public FlashScreenFrm(MainForm mForm):this()
 {
 //有用
 this.Tag=0;
 //保留变量
 _mForm = mForm;
 //设置消息
 label1.Text= "程序初始化";
 //启动 timer1 如果在这里写处理什么也看不到
 timer1.Enabled=true;

 }
 //省略部分。。。。。。。
 private void FlashScreenFrm_Closing(object sender
   , System.ComponentModel.CancelEventArgs e)
 {
  //防止 alt+F4
  if ((int)this.Tag==0)
   e.Cancel=true;
 }

 private void timer1_Tick(object sender, System.EventArgs e)
 {
  DialogResult rVar =DialogResult.Cancel;

  //就运行一次
  timer1.Enabled=false;

  this.label1.Text="程序正在加载请稍后";
  //不加这个就看不到效果
  Application.DoEvents();
  try
  {
   //调用主窗口的计算函数
   _mForm.LoadIClients();

     
   this.label1.Text="程序加载完成....";

   Application.DoEvents();
   //不加这个最后的消息看不见
   System.Threading.Thread.Sleep(100);  
   
   rVar =DialogResult.OK;
  }
  catch(Exception ex)
  {
   MessageBox.Show(ex.ToString());
  }
  finally
  {
   this.Tag = 1;
   this.DialogResult = rVar;
  }
  
 }
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值