c# 创建窗口句柄时出错,求解决办法

aspnetno 2011-12-20 08:14:24
这是看书上做的一个加载窗口的例子,但按按书上原封不动做的,但就是出不来。出错提示就是“创建窗口句柄时出错,未处理win31exception”
WaittingForm.cs文件
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsForms_Sample
{
public partial class WaittingForm : Form
{
public WaittingForm()
{
InitializeComponent();
}

private void WaittingForm_Load(object sender, EventArgs e)
{
WaittingForm waitting = new WaittingForm();
waitting.Show();
waitting.Activate();
Application.DoEvents();
System.Threading.Thread.Sleep(5000);
waitting.Close();
waitting.Dispose();
}
}
}

Program.cs文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace WindowsForms_Sample
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new WaittingForm());//加载窗口
Application.Run(new MainForm()); //主窗口
//注:上面Run两行,如果把MainForm放上面,就不显示等待窗口,直接显示主窗口
}
}
}
...全文
720 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hefeng_aspnet 2011-12-21
  • 打赏
  • 举报
回复
有些树上的代码也有问题的

Form my房态管理 = new 房态管理(0);
for (int x = 0; x < this.MdiChildren.Length; x++)
{
Form tempChild = (Form)this.MdiChildren[x];
tempChild.Close();
}
my房态管理.MdiParent = this;
my房态管理.Show();
break;

111,125

社区成员

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

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

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