当前位置:首页 > 网络编程 > 软件语言 > .NET > 一个多文档界面的应用程序

一个多文档界面的应用程序

点击次数:91 次 发布日期:2008-11-06 07:51:10 作者:源代码网
源代码网推荐
广告载入中
namespace Microsoft.Samples.WinForms.Cs.MDI {
using System;
using System.ComponentModel;
using System.Drawing;
using System.WinForms;

源代码网整理以下

源代码网整理以下public class MainForm : System.WinForms.Form {
private System.ComponentModel.Container components;
private System.WinForms.MainMenu mainMenu;
private System.WinForms.StatusBar statusBar1;

源代码网整理以下private int windowCount = 0 ;

源代码网整理以下public MainForm() {

源代码网整理以下// Required by the Windows Forms Designer
InitializeComponent();

源代码网整理以下// TODO: Add any constructor code after InitializeComponent call

源代码网整理以下//Setup MDI stuff
this.IsMDIContainer = true;
this.MDIChildActivate = new EventHandler(this.MDIChildActivated);

软件开发网 www.mscto.com

源代码网整理以下//Add File Menu
MenuItem miFile = mainMenu.MenuItems.Add("&File");
miFile.MergeOrder=0;
miFile.MergeType = MenuMerge.MergeItems;

源代码网整理以下MenuItem miAddDoc = new MenuItem("&Add Document", new EventHandler(this.FileAdd_Clicked), Shortcut.CtrlA);
miAddDoc.MergeOrder=100;

源代码网整理以下MenuItem miExit = new MenuItem("E&xit", new EventHandler(this.FileExit_Clicked), Shortcut.CtrlX);
miExit.MergeOrder=110;

源代码网整理以下miFile.MenuItems.Add(miAddDoc);
miFile.MenuItems.Add("-"); // Gives us a seperator
miFile.MenuItems.Add(miExit);

源代码网整理以下//Add Window Menu
MenuItem miWindow = mainMenu.MenuItems.Add("&Window");
miWindow.MergeOrder = 10;
miWindow.MenuItems.Add("&Cascade", new EventHandler(this.WindowCascade_Clicked));
miWindow.MenuItems.Add("Tile &Horizontal", new EventHandler(this.WindowTileH_Clicked));
miWindow.MenuItems.Add("Tile &Vertical", new EventHandler(this.WindowTileV_Clicked));
miWindow.MDIList = true ; //Adds the MDI Window List to the bottom of the menu

源代码网整理以下AddDocument(); //Add an initial doc
} 软件开发网 www.mscto.com

源代码网整理以下
//Add a document
private void AddDocument() {
windowCount ;
Document doc = new Document("Document " windowCount);
doc.MDIParent = this;
doc.Show();
}

源代码网整理以下
//File->Add Menu item handler
protected void FileAdd_Clicked(object sender, System.EventArgs e) {
AddDocument() ;
} 软件开发网 www.mscto.com

源代码网整理以下
//File->Exit Menu item handler
protected void FileExit_Clicked(object sender, System.EventArgs e) {
this.Close();
}

源代码网整理以下
//One of the MDI Child windows has been activated
protected void MDIChildActivated(object sender, System.EventArgs e) {
if (null == this.ActiveMDIChild) {
statusBar1.Text = "";
} else {
statusBar1.Text = this.ActiveMDIChild.Text;
}
}

源代码网整理以下//Window->Cascade Menu item handler
protected void WindowCascade_Clicked(object sender, System.EventArgs e) {
this.LayoutMDI(MDILayout.Cascade);
}

源代码网整理以下
//Window->Tile Horizontally Menu item handler
protected void WindowTileH_Clicked(object sender, System.EventArgs e) {
this.LayoutMDI(MDILayout.TileHorizontal);
}

源代码网整理以下
//Window->Tile Vertically Menu item handler
protected void WindowTileV_Clicked(object sender, System.EventArgs e) {
this.LayoutMDI(MDILayout.TileVertical);
}

源代码网整理以下
public override void Dispose() {
base.Dispose();
components.Dispose();
}

源代码网整理以下protected void InitializeComponent() {

软件开发网 www.mscto.com

源代码网整理以下this.components = new System.ComponentModel.Container();
this.mainMenu = new System.WinForms.MainMenu();
this.statusBar1 = new System.WinForms.StatusBar();

源代码网整理以下this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.Text = "MDI Example";
this.Menu = mainMenu;
this.ClientSize = new System.Drawing.Size(450, 200);

源代码网整理以下statusBar1.BackColor = System.Drawing.SystemColors.Control;
statusBar1.Size = new System.Drawing.Size(496, 20);
statusBar1.TabIndex = 1;
statusBar1.Text = "";
statusBar1.Location = new System.Drawing.Point(0, 273); 软件开发网 www.mscto.com

源代码网整理以下this.Controls.Add(statusBar1);
}

源代码网整理以下
public static void Main(string[] args) {
Application.Run(new MainForm());
}

源代码网整理以下}
}

源代码网整理以下
作者:jspfuns

软件开发网 www.mscto.com


源代码网推荐

源代码网供稿.
上一篇: asp 中的hash表操作  下一篇: asp 制作图形
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华