小弟运行程序的时候遇到一个问题,请大家帮忙看看!程序主窗体已经打开,在调用子窗体时候出现了“未处理的System.OutOfMemoryException”类型的异常出现在 system.windows.forms.dll 中。其他信息: 创建窗口句柄时出错。”请大家帮忙指导一下,看看怎么解决!
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 中层干部源管理系统
{
///
/// Form1 的摘要说明。
///
public class frmMain : System.Windows.Forms.Form
{
internal System.Windows.Forms.MainMenu MainMenu;
internal System.Windows.Forms.MenuItem MenuItemDep;
internal System.Windows.Forms.MenuItem MenuItemDepManage;
internal System.Windows.Forms.MenuItem MenuItemDepInfo;
internal System.Windows.Forms.MenuItem MenuItemPeople;
internal System.Windows.Forms.MenuItem MenuItemPeopleManage;
internal System.Windows.Forms.MenuItem MenuItemPeopleQuery;
internal System.Windows.Forms.MenuItem MenuItemSalary;
internal System.Windows.Forms.MenuItem MenuItemSalaryManage;
internal System.Windows.Forms.MenuItem MenuItemTaxInfo;
internal System.Windows.Forms.MenuItem MenuItemSalaryHis;
internal System.Windows.Forms.MenuItem MenuItemPrize;
internal System.Windows.Forms.MenuItem MenuItemPunish;
private System.Windows.Forms.MenuItem menuItemExit;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
public frmMain()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
this.MainMenu = new System.Windows.Forms.MainMenu();
this.MenuItemDep = new System.Windows.Forms.MenuItem();
this.MenuItemDepManage = new System.Windows.Forms.MenuItem();
this.MenuItemDepInfo = new System.Windows.Forms.MenuItem();
this.MenuItemPeople = new System.Windows.Forms.MenuItem();
this.MenuItemPeopleManage = new System.Windows.Forms.MenuItem();
this.MenuItemPeopleQuery = new System.Windows.Forms.MenuItem();
this.MenuItemSalary = new System.Windows.Forms.MenuItem();
this.MenuItemSalaryManage = new System.Windows.Forms.MenuItem();
this.MenuItemTaxInfo = new System.Windows.Forms.MenuItem();
this.MenuItemSalaryHis = new System.Windows.Forms.MenuItem();
this.MenuItemPrize = new System.Windows.Forms.MenuItem();
this.MenuItemPunish = new System.Windows.Forms.MenuItem();
this.menuItemExit = new System.Windows.Forms.MenuItem();
//
// MainMenu
//
this.MainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.MenuItemDep,
this.MenuItemPeople,
this.MenuItemSalary,
this.menuItemExit});
//
// MenuItemDep
//
this.MenuItemDep.Index = 0;
this.MenuItemDep.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.MenuItemDepManage,
this.MenuItemDepInfo});
this.MenuItemDep.Text = "机构编制管理(&X)";
//
// MenuItemDepManage
//
this.MenuItemDepManage.Index = 0;
this.MenuItemDepManage.Text = "机构设置及编码(&Y)";
this.MenuItemDepManage.Click += new System.EventHandler(this.MenuItemDepManage_Click);
//
// MenuItemDepInfo
//
this.MenuItemDepInfo.Index = 1;
this.MenuItemDepInfo.Text = "机构详细信息(&Z)";
this.MenuItemDepInfo.Click += new System.EventHandler(this.MenuItemDepInfo_Click);
//
// MenuItemPeople
//
this.MenuItemPeople.Index = 1;
this.MenuItemPeople.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.MenuItemPeopleManage,
this.MenuItemPeopleQuery});
this.MenuItemPeople.Text = "职员信息管理(&Y)";
//
// MenuItemPeopleManage
//
this.MenuItemPeopleManage.Index = 0;
this.MenuItemPeopleManage.Text = "职员信息维护(&Y)";
this.MenuItemPeopleManage.Click += new System.EventHandler(this.MenuItemPeopleManage_Click);
//
// MenuItemPeopleQuery
//
this.MenuItemPeopleQuery.Index = 1;
this.MenuItemPeopleQuery.Text = "职员信息查询(&Z)";
this.MenuItemPeopleQuery.Click += new System.EventHandler(this.MenuItemPeopleQuery_Click);
//
// MenuItemSalary
//
this.MenuItemSalary.Index = 2;
this.MenuItemSalary.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.MenuItemSalaryManage,
this.MenuItemTaxInfo,
this.MenuItemSalaryHis,
this.MenuItemPrize,
this.MenuItemPunish});
this.MenuItemSalary.Text = "薪资福利管理(&Z)";
//
// MenuItemSalaryManage
//
this.MenuItemSalaryManage.Index = 0;
this.MenuItemSalaryManage.Text = "当月工资计算(&V)";
this.MenuItemSalaryManage.Click += new System.EventHandler(this.MenuItemSalaryManage_Click);
//
// MenuItemTaxInfo
//
this.MenuItemTaxInfo.Index = 1;
this.MenuItemTaxInfo.Text = "个人所得税率(&W)";
this.MenuItemTaxInfo.Click += new System.EventHandler(this.MenuItemTaxInfo_Click);
//
// MenuItemSalaryHis
//
this.MenuItemSalaryHis.Index = 2;
this.MenuItemSalaryHis.Text = "工资发放历史(&X)";
this.MenuItemSalaryHis.Click += new System.EventHandler(this.MenuItemSalaryHis_Click);
//
// MenuItemPrize
//
this.MenuItemPrize.Index = 3;
this.MenuItemPrize.Text = "职员奖励管理(&Y)";
this.MenuItemPrize.Click += new System.EventHandler(this.MenuItemPrize_Click);
//
// MenuItemPunish
//
this.MenuItemPunish.Index = 4;
this.MenuItemPunish.Text = "职员惩罚管理(&Z)";
this.MenuItemPunish.Click += new System.EventHandler(this.MenuItemPunish_Click);
//
// menuItemExit
//
this.menuItemExit.Index = 3;
this.menuItemExit.Text = "退出系统(&S)";
this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(440, 284);
this.IsMdiContainer = true;
this.Menu = this.MainMenu;
this.Name = "frmMain";
this.Text = "人力资源管理系统";
this.Load += new System.EventHandler(this.frmMain_Load);
}
#endregion
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}
private bool GetInstanceState( string name )
{
int l = this.MdiChildren.Length;
for ( int i = 0; i < l; i ++ )
{
if ( this.MdiChildren[ i ].Name == name )
{
this.MdiChildren [ i ].Focus();
return true;
}
}
return false;
}
private void MenuItemDepInfo_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmDepInfo" ) )
{
return;
}
frmDepInfo childFrm = new frmDepInfo();
childFrm.MdiParent = this;
childFrm.Show();
}
private void MenuItemDepManage_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmDepManage" ) )
{
return;
}
frmDepManage childFrm = new frmDepManage();
childFrm.MdiParent = this;
childFrm.Show();
}
private void MenuItemPeopleManage_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmPeopleManage" ) )
{
return;
}
frmPeopleManage childFrm = new frmPeopleManage();
childFrm.MdiParent =this;
childFrm.Show();
}//这里有一个错误。错误的提示是“未处理的“System.OutOfMemoryException”类型的异常出现在 system.windows.forms.dll 中。其他信息: 创建窗口句柄时出错。”
private void MenuItemPeopleQuery_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmPeopleQuery" ) )
{
return;
}
frmPeopleQuery childFrm = new frmPeopleQuery();
childFrm.MdiParent = this;
childFrm.Show();
}
private void MenuItemSalaryManage_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmSalaryManage" ) )
{
return;
}
frmSalaryManage childFrm = new frmSalaryManage();
childFrm.MdiParent = this;
childFrm.Show();
}
private void MenuItemTaxInfo_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmTaxInfo" ) )
{
return;
}
frmTaxInfo childFrm = new frmTaxInfo();
childFrm.MdiParent = this;
childFrm.Show();
}
private void MenuItemSalaryHis_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmSalaryHis" ) )
{
return;
}
frmSalaryHis childFrm = new frmSalaryHis();
childFrm.MdiParent = this;
childFrm.Show();
}
private void MenuItemPrize_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmPrize" ) )
{
return;
}
frmPrize childFrm = new frmPrize();
childFrm.MdiParent = this;
childFrm.Show();
}
private void MenuItemPunish_Click(object sender, System.EventArgs e)
{
if( GetInstanceState( "frmPunish" ) )
{
return;
}
frmPunish childFrm = new frmPunish();
childFrm.MdiParent = this;
childFrm.Show();
}
private void frmMain_Load(object sender, System.EventArgs e)
{
}
private void menuItemExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
我不知道怎么解决了 请大家帮帮忙啊!