diff --git a/COURS01/FAccueil.cs b/COURS01/FAccueil.cs index eee1bd4..52b77d5 100644 --- a/COURS01/FAccueil.cs +++ b/COURS01/FAccueil.cs @@ -49,10 +49,9 @@ namespace COURS01 private void btnEntrez_Click(object sender, EventArgs e) { - EcranPrincipal f = new EcranPrincipal(); + EcranPrincipal f = new EcranPrincipal(this); this.Hide(); f.ShowDialog();//Bloque la fenetre parrent alors que show ne bloque pas le parent - this.Show(); } } } diff --git a/COURS01/FPrincipal.Designer.cs b/COURS01/FPrincipal.Designer.cs index a740743..312695e 100644 --- a/COURS01/FPrincipal.Designer.cs +++ b/COURS01/FPrincipal.Designer.cs @@ -30,11 +30,11 @@ { this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.mFenetre = new System.Windows.Forms.ToolStripMenuItem(); - this.mAide = new System.Windows.Forms.ToolStripMenuItem(); - this.mQuitter = new System.Windows.Forms.ToolStripMenuItem(); this.mfProgression = new System.Windows.Forms.ToolStripMenuItem(); this.mfListe = new System.Windows.Forms.ToolStripMenuItem(); this.mfEditeur = new System.Windows.Forms.ToolStripMenuItem(); + this.mAide = new System.Windows.Forms.ToolStripMenuItem(); + this.mQuitter = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -60,22 +60,6 @@ this.mFenetre.Size = new System.Drawing.Size(58, 20); this.mFenetre.Text = "Fenêtre"; // - // mAide - // - this.mAide.Name = "mAide"; - this.mAide.ShortcutKeys = System.Windows.Forms.Keys.F1; - this.mAide.Size = new System.Drawing.Size(43, 20); - this.mAide.Text = "Aide"; - this.mAide.Click += new System.EventHandler(this.mNDef_Click); - // - // mQuitter - // - this.mQuitter.Name = "mQuitter"; - this.mQuitter.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); - this.mQuitter.Size = new System.Drawing.Size(56, 20); - this.mQuitter.Text = "Quitter"; - this.mQuitter.Click += new System.EventHandler(this.mQuitter_Click); - // // mfProgression // this.mfProgression.Name = "mfProgression"; @@ -97,6 +81,22 @@ this.mfEditeur.Text = "Editeur"; this.mfEditeur.Click += new System.EventHandler(this.mNDef_Click); // + // mAide + // + this.mAide.Name = "mAide"; + this.mAide.ShortcutKeys = System.Windows.Forms.Keys.F1; + this.mAide.Size = new System.Drawing.Size(43, 20); + this.mAide.Text = "Aide"; + this.mAide.Click += new System.EventHandler(this.mNDef_Click); + // + // mQuitter + // + this.mQuitter.Name = "mQuitter"; + this.mQuitter.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); + this.mQuitter.Size = new System.Drawing.Size(56, 20); + this.mQuitter.Text = "Quitter"; + this.mQuitter.Click += new System.EventHandler(this.mQuitter_Click); + // // EcranPrincipal // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -109,6 +109,7 @@ this.MinimizeBox = false; this.Name = "EcranPrincipal"; this.Text = "Ecran Principal"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.mQuitter_Click); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.ResumeLayout(false); diff --git a/COURS01/FPrincipal.cs b/COURS01/FPrincipal.cs index b28c782..c956692 100644 --- a/COURS01/FPrincipal.cs +++ b/COURS01/FPrincipal.cs @@ -12,15 +12,47 @@ namespace COURS01 { public partial class EcranPrincipal : Form { + Form parentToClose; + bool parentToCloseF; public EcranPrincipal() { + parentToCloseF = false; InitializeComponent(); } - + public EcranPrincipal(Form parentToClose) + { + parentToCloseF = true; + InitializeComponent(); + this.parentToClose = parentToClose; + } private void mQuitter_Click(object sender, EventArgs e) { - Close(); + if(parentToCloseF) + { + parentToClose.Close(); + if (parentToClose.IsDisposed) + Close(); + } + else + Close(); } + + private void mQuitter_Click(object sender, FormClosingEventArgs e) + { + if (parentToCloseF) + { + parentToClose.Close(); + if (parentToClose.IsDisposed) + { + e.Cancel = false; + } + else + e.Cancel = true; + } + else + e.Cancel = false; + } + private void mNDef_Click(object sender, EventArgs e) { MessageBox.Show("Fonctionnalité non implémentée"); diff --git a/COURS01/bin/Debug/COURS01.exe b/COURS01/bin/Debug/COURS01.exe index 40df7a9..4b3dc29 100644 Binary files a/COURS01/bin/Debug/COURS01.exe and b/COURS01/bin/Debug/COURS01.exe differ diff --git a/COURS01/bin/Debug/COURS01.pdb b/COURS01/bin/Debug/COURS01.pdb index c60cf80..134d772 100644 Binary files a/COURS01/bin/Debug/COURS01.pdb and b/COURS01/bin/Debug/COURS01.pdb differ diff --git a/COURS01/obj/Debug/COURS01.csproj.GenerateResource.Cache b/COURS01/obj/Debug/COURS01.csproj.GenerateResource.Cache index f4e95b8..761827a 100644 Binary files a/COURS01/obj/Debug/COURS01.csproj.GenerateResource.Cache and b/COURS01/obj/Debug/COURS01.csproj.GenerateResource.Cache differ diff --git a/COURS01/obj/Debug/COURS01.exe b/COURS01/obj/Debug/COURS01.exe index 40df7a9..4b3dc29 100644 Binary files a/COURS01/obj/Debug/COURS01.exe and b/COURS01/obj/Debug/COURS01.exe differ diff --git a/COURS01/obj/Debug/COURS01.pdb b/COURS01/obj/Debug/COURS01.pdb index c60cf80..134d772 100644 Binary files a/COURS01/obj/Debug/COURS01.pdb and b/COURS01/obj/Debug/COURS01.pdb differ