怎样用visual C#中制作启动画面 http://www.reflectionit.nl/Splash.aspx 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 you can use From(Start from) and a timer! using System;using System.Drawing;using System.Windows.Forms;using System.Threading;namespace YourNameSpace{public sealed class SplashScreen{ static SplashForm m_SplashForm; static Thread m_WorkerThread; private SplashScreen() { } static SplashScreen() { m_SplashForm = new SplashForm(); m_SplashForm.SplashImage = Resources.bmpEffortechSplash; } public static Image SplashImage { get { return m_SplashForm.SplashImage; } set { m_SplashForm.SplashImage = value; } } public static string InfoText { get { return m_SplashForm.InfoText; } set { m_SplashForm.InfoText = value; } } public static void Show(Bitmap splashImage) { if (splashImage == null) throw new ArgumentNullException(); m_SplashForm.SplashImage = splashImage; Show(); } public static void Show() { ThreadStart threadStart = new ThreadStart(ShowForm); m_SplashForm.HideSplash = false; m_WorkerThread = new Thread(threadStart); m_WorkerThread.Start(); } private static void ShowForm() { m_SplashForm.ShowDialog(); } public static void Close() { if (m_SplashForm != null && !m_SplashForm.IsDisposed) m_SplashForm.HideSplash = true; //m_WorkerThread.Join(); } public static void Dispose() { if (m_SplashForm != null) m_SplashForm.Dispose(); m_SplashForm = null; }}internal class SplashForm : Form{ private System.Windows.Forms.Timer timer1; private PictureBox m_SplashPictureBox; private System.ComponentModel.IContainer components; private bool m_HideSplash = false; private System.Windows.Forms.Timer timer2; private Point orgPoint; internal System.Windows.Forms.Label InfoLabel; public SplashForm() { InitializeComponent(); this.timer1.Start(); } #region Windows Form Designer generated code private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.m_SplashPictureBox = new System.Windows.Forms.PictureBox(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.InfoLabel = new System.Windows.Forms.Label(); this.timer2 = new System.Windows.Forms.Timer(this.components); this.SuspendLayout(); // // m_SplashPictureBox // this.m_SplashPictureBox.Cursor = System.Windows.Forms.Cursors.AppStarting; this.m_SplashPictureBox.Name = "m_SplashPictureBox"; this.m_SplashPictureBox.Size = new System.Drawing.Size(112, 80); this.m_SplashPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.m_SplashPictureBox.TabIndex = 0; this.m_SplashPictureBox.TabStop = false; this.m_SplashPictureBox.Click += new System.EventHandler(this.m_SplashPictureBox_Click); this.m_SplashPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp); this.m_SplashPictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); this.m_SplashPictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown); // // timer1 // this.timer1.Enabled = true; this.timer1.Interval = 500; this.timer1.Tick += new System.EventHandler(this.OnTick); // // InfoLabel // this.InfoLabel.BackColor = System.Drawing.Color.Aqua; this.InfoLabel.Cursor = System.Windows.Forms.Cursors.Default; this.InfoLabel.Dock = System.Windows.Forms.DockStyle.Bottom; this.InfoLabel.Location = new System.Drawing.Point(0, 286); this.InfoLabel.Name = "InfoLabel"; this.InfoLabel.Size = new System.Drawing.Size(415, 19); this.InfoLabel.TabIndex = 1; this.InfoLabel.Text = "正在启动 ..."; this.InfoLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.InfoLabel.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp); this.InfoLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove); this.InfoLabel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown); // // timer2 // this.timer2.Interval = 5000; this.timer2.Tick += new System.EventHandler(this.timer2_Tick); // // SplashForm // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(415, 305); this.ControlBox = false; this.Controls.AddRange(new System.Windows.Forms.Control[] { this.m_SplashPictureBox, this.InfoLabel}); this.Cursor = System.Windows.Forms.Cursors.Cross; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.Name = "SplashForm"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.TopMost = true; this.ResumeLayout(false); } #endregion private void OnTick(object sender,EventArgs e) { if(HideSplash == true) { this.timer1.Enabled = false; this.timer2.Enabled = true; } } private void m_SplashPictureBox_Click(object sender, System.EventArgs e) { if (this.timer1.Enabled == false) { this.timer2.Stop(); this.timer1.Dispose(); this.timer2.Dispose(); this.m_SplashPictureBox.Dispose(); this.Close(); } } private void OnMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { this.Cursor = Cursors.SizeAll; orgPoint = new Point(e.X,e.Y); orgPoint = this.PointToScreen(orgPoint); } private void OnMouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { this.Cursor = Cursors.Default; } private void OnMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if(e.Button==MouseButtons.Left) { Point tp = new Point(e.X,e.Y); tp = this.PointToScreen(tp); this.Top += tp.Y -orgPoint.Y; this.Left += tp.X-orgPoint.X; this.orgPoint = tp; } } private void timer2_Tick(object sender, System.EventArgs e) { this.timer2.Stop(); this.timer1.Dispose(); this.timer2.Dispose(); this.m_SplashPictureBox.Dispose(); this.Close(); } public bool HideSplash { get { return m_HideSplash; } set { lock(this) { m_HideSplash = value; } } } public string InfoText { get { lock(this) { return this.InfoLabel.Text; } } set { lock(this) { this.InfoLabel.Text = value; } } } public Image SplashImage { get { return this.m_SplashPictureBox.Image; } set { if (m_SplashPictureBox.Image == value) return; m_SplashPictureBox.Image = value; this.ClientSize = new Size(m_SplashPictureBox.Size.Width, m_SplashPictureBox.Size.Height + this.InfoLabel.Height); } }}} http://www.codeproject.com/csharp/apploadingarticle.asp?target=splash 求正则? 请大神指点错在哪里? c#里如果点击子窗口,父窗口也随之关闭 程序关闭时出错!!急 无法加载 DLL“..\..\mi.dll”: 内存分配访问无效。 (异常来自 HRESULT:0x800703E6) 再提treeview问题 获取gridview行中所有列显示的东西 数据库连接问题 请问一个界面编写的问题? 3个问题,每个问题20分! 用C Sharp怎样实现软件启动画面? 我想问一下win98 下怎么运行c#程序,是不是安装好framework就可以了?需不需要安装pws?
using System.Drawing;
using System.Windows.Forms;
using System.Threading;namespace YourNameSpace
{
public sealed class SplashScreen
{
static SplashForm m_SplashForm;
static Thread m_WorkerThread;
private SplashScreen()
{
} static SplashScreen()
{
m_SplashForm = new SplashForm();
m_SplashForm.SplashImage = Resources.bmpEffortechSplash;
} public static Image SplashImage
{
get
{
return m_SplashForm.SplashImage;
}
set
{
m_SplashForm.SplashImage = value;
}
} public static string InfoText
{
get
{
return m_SplashForm.InfoText;
}
set
{
m_SplashForm.InfoText = value;
}
} public static void Show(Bitmap splashImage)
{
if (splashImage == null)
throw new ArgumentNullException(); m_SplashForm.SplashImage = splashImage;
Show();
} public static void Show()
{
ThreadStart threadStart = new ThreadStart(ShowForm);
m_SplashForm.HideSplash = false;
m_WorkerThread = new Thread(threadStart);
m_WorkerThread.Start();
} private static void ShowForm()
{
m_SplashForm.ShowDialog();
} public static void Close()
{
if (m_SplashForm != null && !m_SplashForm.IsDisposed)
m_SplashForm.HideSplash = true;
//m_WorkerThread.Join();
}
public static void Dispose()
{
if (m_SplashForm != null)
m_SplashForm.Dispose();
m_SplashForm = null;
}
}internal class SplashForm : Form
{
private System.Windows.Forms.Timer timer1;
private PictureBox m_SplashPictureBox;
private System.ComponentModel.IContainer components;
private bool m_HideSplash = false;
private System.Windows.Forms.Timer timer2;
private Point orgPoint; internal System.Windows.Forms.Label InfoLabel;
public SplashForm()
{
InitializeComponent();
this.timer1.Start();
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.m_SplashPictureBox = new System.Windows.Forms.PictureBox();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.InfoLabel = new System.Windows.Forms.Label();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// m_SplashPictureBox
//
this.m_SplashPictureBox.Cursor = System.Windows.Forms.Cursors.AppStarting;
this.m_SplashPictureBox.Name = "m_SplashPictureBox";
this.m_SplashPictureBox.Size = new System.Drawing.Size(112, 80);
this.m_SplashPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.m_SplashPictureBox.TabIndex = 0;
this.m_SplashPictureBox.TabStop = false;
this.m_SplashPictureBox.Click += new System.EventHandler(this.m_SplashPictureBox_Click);
this.m_SplashPictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp);
this.m_SplashPictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
this.m_SplashPictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown);
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 500;
this.timer1.Tick += new System.EventHandler(this.OnTick);
//
// InfoLabel
//
this.InfoLabel.BackColor = System.Drawing.Color.Aqua;
this.InfoLabel.Cursor = System.Windows.Forms.Cursors.Default;
this.InfoLabel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.InfoLabel.Location = new System.Drawing.Point(0, 286);
this.InfoLabel.Name = "InfoLabel";
this.InfoLabel.Size = new System.Drawing.Size(415, 19);
this.InfoLabel.TabIndex = 1;
this.InfoLabel.Text = "正在启动 ...";
this.InfoLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.InfoLabel.MouseUp += new System.Windows.Forms.MouseEventHandler(this.OnMouseUp);
this.InfoLabel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.OnMouseMove);
this.InfoLabel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OnMouseDown);
//
// timer2
//
this.timer2.Interval = 5000;
this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
//
// SplashForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(415, 305);
this.ControlBox = false;
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.m_SplashPictureBox,
this.InfoLabel});
this.Cursor = System.Windows.Forms.Cursors.Cross;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "SplashForm";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.TopMost = true;
this.ResumeLayout(false); }
#endregion private void OnTick(object sender,EventArgs e)
{
if(HideSplash == true)
{
this.timer1.Enabled = false;
this.timer2.Enabled = true;
}
} private void m_SplashPictureBox_Click(object sender, System.EventArgs e)
{
if (this.timer1.Enabled == false)
{
this.timer2.Stop();
this.timer1.Dispose();
this.timer2.Dispose();
this.m_SplashPictureBox.Dispose();
this.Close();
}
} private void OnMouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Cursor = Cursors.SizeAll;
orgPoint = new Point(e.X,e.Y);
orgPoint = this.PointToScreen(orgPoint);
} private void OnMouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.Cursor = Cursors.Default;
} private void OnMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button==MouseButtons.Left)
{
Point tp = new Point(e.X,e.Y);
tp = this.PointToScreen(tp);
this.Top += tp.Y -orgPoint.Y;
this.Left += tp.X-orgPoint.X;
this.orgPoint = tp;
}
}
private void timer2_Tick(object sender, System.EventArgs e)
{
this.timer2.Stop();
this.timer1.Dispose();
this.timer2.Dispose();
this.m_SplashPictureBox.Dispose();
this.Close();
} public bool HideSplash
{
get
{
return m_HideSplash;
}
set
{
lock(this)
{
m_HideSplash = value;
}
}
} public string InfoText
{
get
{
lock(this)
{
return this.InfoLabel.Text;
}
}
set
{
lock(this)
{
this.InfoLabel.Text = value;
}
}
} public Image SplashImage
{
get
{
return this.m_SplashPictureBox.Image;
}
set
{
if (m_SplashPictureBox.Image == value)
return;
m_SplashPictureBox.Image = value;
this.ClientSize = new Size(m_SplashPictureBox.Size.Width,
m_SplashPictureBox.Size.Height + this.InfoLabel.Height);
}
}}
}