Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Fenêtre MDI: Dimension cascade et Mosaïque

Fenêtre,MDI:,Dimension,cascade,et,Mosaïque
{filelink=14624}

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
 
public class ExempleMDI : Form
{
      private System.Windows.Forms.MenuStrip menuFichier;
      private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
      private System.Windows.Forms.ToolStripMenuItem nouveauMenuItem;
      private System.Windows.Forms.ToolStripMenuItem quitterMenuItem;
      private System.Windows.Forms.ToolStripMenuItem child1ToolStripMenuItem;
      private System.Windows.Forms.ToolStripMenuItem menuFenetre;
      private System.Windows.Forms.ToolStripMenuItem cascadeToolStripMenuItem;
      private System.Windows.Forms.ToolStripMenuItem mosaiqueHorizontalToolStripMenuItem;
      private System.Windows.Forms.ToolStripMenuItem mosaiqueVerticalToolStripMenuItem;
      private System.Windows.Forms.ToolStripSeparator separateurMenu;
 
      public ExempleMDI() {
        InitializeComponent();
      }
      private void child1ToolStripMenuItem_Click(object sender, EventArgs e ){
          String urlImage = @"C:Documents and SettingsAdministrateurMes documentshalf.png";
        ChildForm formChild = new ChildForm("Fenêtre Fille MDI", urlImage );
        formChild.MdiParent = this;
        formChild.Show();
     }
 
     private void cascadeToolStripMenuItem_Click(object sender, EventArgs e ) {
       this.LayoutMdi( MdiLayout.Cascade );
     } 
 
     private void mosaiqueHorizontalToolStripMenuItem_Click(object sender, EventArgs e ) {
       this.LayoutMdi( MdiLayout.TileHorizontal );
     }
     private void mosaiqueVerticalToolStripMenuItem_Click(object sender, EventArgs e ) {
       this.LayoutMdi( MdiLayout.TileVertical );
     }
     private void InitializeComponent() {
         this.menuFichier = new System.Windows.Forms.MenuStrip();
         this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.nouveauMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.child1ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.quitterMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.menuFenetre = new System.Windows.Forms.ToolStripMenuItem();
         this.cascadeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.mosaiqueHorizontalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.mosaiqueVerticalToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
         this.separateurMenu = new System.Windows.Forms.ToolStripSeparator();
         this.menuFichier.SuspendLayout();
         this.SuspendLayout();
         //
         // menuFichier
         //
         this.menuFichier.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem,
            this.menuFenetre});
         this.menuFichier.Location = new System.Drawing.Point(0, 0);
         this.menuFichier.MdiWindowListItem = this.menuFenetre;
         this.menuFichier.Name = "menuFichier";
         this.menuFichier.Size = new System.Drawing.Size(353, 24);
         this.menuFichier.TabIndex = 1;
         this.menuFichier.Text = "menuFichier";
 
         this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.nouveauMenuItem,
            this.quitterMenuItem});
         this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
         this.fileToolStripMenuItem.Text = "Fichier";
        //
         // Les options de menu Fichier
         //
         this.nouveauMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.child1ToolStripMenuItem});
         this.nouveauMenuItem.Name = "nouveauMenuItem";
         this.nouveauMenuItem.Text = "Nouveau";
 
         this.child1ToolStripMenuItem.Name = "child1ToolStripMenuItem";
         this.child1ToolStripMenuItem.Text = "Nouvelle Fenêtre";
         this.child1ToolStripMenuItem.Click += new System.EventHandler(this.child1ToolStripMenuItem_Click);
         //
         // Option Quitter
         //
         this.quitterMenuItem.Name = "quitterMenuItem";
         this.quitterMenuItem.Text = "Quitter";
         //
         // menu Fenetre
         //
         this.menuFenetre.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.cascadeToolStripMenuItem,
            this.mosaiqueHorizontalToolStripMenuItem,
            this.mosaiqueVerticalToolStripMenuItem,
            this.separateurMenu});
         this.menuFenetre.Name = "menuFenetre";
         this.menuFenetre.Text = "Fenêtre";
         //
         // cascadeToolStripMenuItem
         //
         this.cascadeToolStripMenuItem.Name = "cascadeToolStripMenuItem";
         this.cascadeToolStripMenuItem.Text = "Cascade";
         this.cascadeToolStripMenuItem.Click += new System.EventHandler(this.cascadeToolStripMenuItem_Click);
         //
         // mosaiqueHorizontalToolStripMenuItem
         //
         this.mosaiqueHorizontalToolStripMenuItem.Name = "mosaiqueHorizontalToolStripMenuItem";
         this.mosaiqueHorizontalToolStripMenuItem.Text = "Mosaïque Horizontale";
         this.mosaiqueHorizontalToolStripMenuItem.Click += new System.EventHandler(this.mosaiqueHorizontalToolStripMenuItem_Click);
         //
         // mosaiqueVerticalToolStripMenuItem
         //
         this.mosaiqueVerticalToolStripMenuItem.Name = "mosaiqueVerticalToolStripMenuItem";
         this.mosaiqueVerticalToolStripMenuItem.Text = "Mosaïque Vertical";
         this.mosaiqueVerticalToolStripMenuItem.Click += new System.EventHandler(this.mosaiqueVerticalToolStripMenuItem_Click);
         //
         // separateurMenu
         //
         this.separateurMenu.Name = "separateurMenu";
         //
         // etatFenetreMDI
         //
         this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
         this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
         this.ClientSize = new System.Drawing.Size(353, 310);
         this.Controls.Add(this.menuFichier);
         this.IsMdiContainer = true;
         this.MainMenuStrip = this.menuFichier;
         this.Name = "etatFenetreMDI";
         this.Text = "Utilisation Fenêtre MDI";
         this.menuFichier.ResumeLayout(false);
         this.ResumeLayout(false);
         this.PerformLayout();
 
      }
 
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new ExempleMDI());
    }
}
 
public class ChildForm : Form
{
   private System.Windows.Forms.PictureBox afficheImage;
 
   public ChildForm( string title, string fileName )
   {
      InitializeComponent();
 
      Text = title; 
 
      afficheImage.Image = Image.FromFile(fileName);
   }
 
   private void InitializeComponent() {
         this.afficheImage = new System.Windows.Forms.PictureBox();
         ((System.ComponentModel.ISupportInitialize)(this.afficheImage)).BeginInit();
         this.SuspendLayout();
         //
         // afficheImage
         //
         this.afficheImage.Location = new System.Drawing.Point(1, 7);
         this.afficheImage.Name = "afficheImage";
         this.afficheImage.Size = new System.Drawing.Size(225, 247);
         this.afficheImage.TabIndex = 0;
         this.afficheImage.TabStop = false;
 
         this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
         this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
         this.ClientSize = new System.Drawing.Size(227, 256);
         this.Controls.Add(this.afficheImage);
         this.Name = "ChildForm";
         this.Text = "Enfant";
         ((System.ComponentModel.ISupportInitialize)(this.afficheImage)).EndInit();
         this.ResumeLayout(false);
 
      }
}

No comments yet.

Leave a Comment