Click here to Skip to main content
15,884,298 members
Articles / Multimedia / GDI+

MdiClient Revisited

Rate me:
Please Sign up or sign in to vote.
4.53/5 (18 votes)
13 Oct 20043 min read 84.8K   2.2K   35  
Drawing background of MDI window using 100% managed code, including design time support.
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace GradientFormTest
{
	public class MainForm : MdiFormBackground.GradientForm
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem menuItem2;
		private System.Windows.Forms.MenuItem menuItem3;
		private System.ComponentModel.IContainer components = null;

		public MainForm()
		{
			// This call is required by the Windows Form Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitializeComponent call
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem1});
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 0;
			this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItem2,
																					  this.menuItem3});
			this.menuItem1.Text = "Gradient";
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 0;
			this.menuItem2.Text = "Form1";
			this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 1;
			this.menuItem3.Text = "Form2";
			this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
			// 
			// MainForm
			// 
			this.Angle = 235;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.SystemColors.Control;
			this.BackColor2 = System.Drawing.Color.RoyalBlue;
			this.ClientSize = new System.Drawing.Size(576, 353);
			this.IsMdiContainer = true;
			this.Menu = this.mainMenu1;
			this.Name = "MainForm";
			this.Text = "Gradient Form";
			this.Load += new System.EventHandler(this.Form1_Load);

		}
		#endregion

		private void Form1_Load(object sender, System.EventArgs e)
		{
		}

		private void menuItem2_Click(object sender, System.EventArgs e)
		{
			Form form = new Form1();
			form.MdiParent = this;
			form.Show();
		
		}

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			Form form = new Form2();
			form.MdiParent = this;
			form.Show();
		
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
Germany Germany
Erdal HALICI
Freelance IT-Consultant, Project Solution Architect
Hamburg-Germany
www.erdalhalici.com

Comments and Discussions