各位老师,在WINFORM里,怎么样才能知道一个FORM加载完毕? 我现在想做一个启动画面,也就是在点击按钮后,先出现启动画面,同时主画面也同时启动,等主画面加载完毕后,把启动画面关闭!现在我做的是定时关闭启动画面,主画面一开始是隐藏,等关闭启动画面后再把主画面显示出来!请问该怎么得到?或者有类似更好的方法做启动画面的?请各位老师指导! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 如果你没有多线程加载的话,执行到form初始化的最后一句就是加载完毕的时候 to:fsdy2000(乡愁)请问具体怎么实现?FORM加载完毕后的判断标志是什么?有没有具体的确代码? 发消息,这个最保险了。Form_Load里发自定义消息。然后处理。肯定是加载结束了。 using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Runtime.InteropServices;namespace TestInitForm{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.Size = new System.Drawing.Size(300,300); this.Text = "Form1"; PostMessage((int)Handle,1025,0,0); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } [DllImport("user32.dll", EntryPoint="PostMessage")] public static extern int PostMessage ( int hwnd, int wMsg, int wParam, int lParam ); protected override void WndProc(ref Message m) { if (m.Msg == 1025) { MessageBox.Show("Form initialize complate."); } base.WndProc (ref m); } }} 最简单的就这样行了,不过最好建议用多线程using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using System.Threading;namespace 启动画面{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class Mains : System.Windows.Forms.Form { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Mains() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } private void Main_Load(object sender, System.EventArgs e) { this.Visible=false; fwin f=new fwin(); f.Show(); f.Refresh(); Doing(); f.Close(); this.Visible=true; } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { // // Main // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 266); this.Name = "Main"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Main_Load); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Mains()); } void Doing() { Thread.Sleep(10000); } }} 上面的fwin是一个启动窗口的类 有一个List<int>,要全部加1,求最简单的写法。 如何更改通过 数据源--详细列表 拖拽到窗体中的数据 调试程序出错。。找高人解答! Dotfuscator严重的问题!用过的朋友请进... 跪求C#多线程群发邮件解决方法!! 该字符串未被识别为有效的 DateTime。有一个从索引 0 处开始的未知字。 问一个vb.net语句c#的写法 问一个菜的不能再菜的问题 datagrid问题 或者说是DATAVIEW的问题 请教 Help Me! 关于接口(高手请进) 页面控件的值 怎么放到 javascript的数组里?
请问具体怎么实现?
FORM加载完毕后的判断标志是什么?
有没有具体的确代码?
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;namespace TestInitForm
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
PostMessage((int)Handle,1025,0,0);
}
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} [DllImport("user32.dll", EntryPoint="PostMessage")]
public static extern int PostMessage (
int hwnd,
int wMsg,
int wParam,
int lParam
); protected override void WndProc(ref Message m)
{
if (m.Msg == 1025)
{
MessageBox.Show("Form initialize complate.");
}
base.WndProc (ref m);
} }
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;namespace 启动画面
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Mains : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Mains()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} private void Main_Load(object sender, System.EventArgs e)
{
this.Visible=false;
fwin f=new fwin();
f.Show();
f.Refresh();
Doing();
f.Close();
this.Visible=true;
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Main
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Main";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Main_Load); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Mains());
} void Doing()
{
Thread.Sleep(10000);
}
}
}