如何在C#程序初始化的时候显示一个窗口,就像photoshop那样的?

magicblue 2003-12-14 06:40:09
我记得VC是可以通过添加控件实现,C#呢?
...全文
173 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
poseidonliu 2004-01-06
  • 打赏
  • 举报
回复
mark
laodeng72586 2003-12-14
  • 打赏
  • 举报
回复
关注
magicblue 2003-12-14
  • 打赏
  • 举报
回复
thanks!
FileNewExit 2003-12-14
  • 打赏
  • 举报
回复
try:

using System;
using System.Windows.Forms;
using System.Threading;


public class Splasher
{
private Form splash = null;
private Thread SplashThread = null;

private Label label1 = null;
public Splasher(Form splashForm,Label label)
{
splash = splashForm;
this.label1 = label;
}
public Splasher(Form splashForm):this(splashForm,null){
}
public void Show()
{
if(SplashThread == null)
{
SplashThread = new Thread(new ThreadStart(ShowThread));
SplashThread.IsBackground = true;//后台运行
SplashThread.ApartmentState = ApartmentState.STA;//单线程
SplashThread.Start();
}
}
private void ShowThread()
{
splash.ShowDialog();
}

public string StatusInfo
{
set
{//only setter,no getter
if(splash != null && label1 != null)
{
label1.Text = value;//这决定了你要显示的界面的类中要如果有一Label,其Modifier须为public
//splash.Update();//只修改了label1.Text,这句可以不写
}
}
get{
return this.label1.Text;
}
}

public void Close(){
if(SplashThread != null)
SplashThread = null;
if(splash != null)
{
splash.Close();
splash = null;
}

}
}


=============================
Usage:

public Form1()
{
SplashScreen ss = new SplashScreen();
Splasher splash = new Splasher(ss,ss.label);
splash.Show();
splash.StatusInfo = "Loading your profile.......";
System.Threading.Thread.Sleep(2000);
splash.StatusInfo = "Connect.......";
System.Threading.Thread.Sleep(2000);
splash.StatusInfo = "Loading.......";
//...more work
splash.Close();

}

其中SplashScreen是一个Form,
----FormBoderStyle : Sizeable->None;
---StartPosition :WindowsDefaultLocation->CenterScreen
---ShowInTaskbar :true->false
以上是最基本的要修改的属性.当然还可以修改BackgroundColor,TopMost等属性来达到美观.
本例添加一个PictureBox――pictureBox1,设置其Image属性为自己想显示的图片.另外,再添加一个Label――label1,来反映当前正在进行的初始化工作.
速马 2003-12-14
  • 打赏
  • 举报
回复
main里面启动一个新的线程,打开一个普通的form
simanh 2003-12-14
  • 打赏
  • 举报
回复
做1个form用来放picture,然后在
static void Main()
{
}
中运行主form前运行那个form一段时间(循环)退出后继续运行主form
烤火的鱼 2003-12-14
  • 打赏
  • 举报
回复
象普通form一样创建一个窗口,在程序的主窗口的Load中用FlashForm myForm=new FlasForm();myForm.Show();来启动它,完成了处理之后用myForm.Close()关闭。

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧