Overblog
Editer l'article Suivre ce blog Administration + Créer mon blog

Applications MDI

9 Avril 2016 , Rédigé par Ghislain Martin Publié dans #DEVELOP, #CSHARP

SALUT !!

Oui, oui, je suis toujours vivant. Bon. Dernièrement, je me suis remis à développer des petits programmes en C# via SharpDevelop. Et dans mes expérimentations, je voulais faire une application MDI. Alors ouais, je sais, c'est vieillot, mais je sais pas, j'aime. Problème, je voulais un comportement un peu particulier, pour émuler du DSI complexe avec du MDI. Alors j'ai cherché all over the web, pour trouver quelques trucs et astuces. Du coup je partage les trouvailles, on sait jamais, ça peut aider...

LANCEMENT MAXIMIZED ET UNE SEULE INSTANCE POUR CHAQUE MDI CHILD FORM :

FormPlay frmPlay;

void TestToolStripMenuItemClick(object sender, EventArgs e)
{
    if (frmPlay == null) {
        frmPlay = new FormPlay();
        frmPlay.MdiParent = this;
        frmPlay.FormClosed += new FormClosedEventHandler(frmPlay_FormClosed);
    }
    frmPlay.WindowState = FormWindowState.Maximized;
    frmPlay.Show();
    frmPlay.BringToFront();
    frmPlay.Activate();
}

void frmPlay_FormClosed(object sender, FormClosedEventArgs e)
{
    frmPlay = null;
}

NE PAS POUVOIR REDIMENSIONNER UNE MDI CHILD FORM :

void FormPlayResize(object sender, EventArgs e)
{
    WindowState = FormWindowState.Maximized;
}

SUPPRIMER ICONE ET BOUTONS MINIMISE / RESIZE / MAXIMIZE / CLOSE :

frmPlay.ControlBox = false;

Voilà, c'est tout pour aujourd'hui. J'ai testé un peu ces différentes solutions, histoire de m'approcher au mieux du comportement que je souhaitais avoir. Maintenant, finie la veille technologique, il faut mettre en pratique. Donc j'y retourne. Mais sachez qu'il existe d'autres possibilités, pour cacher le texte, cacher juste l'icône, cacher certains boutons. Mais attention, parfois, le résultat est différent selon que la MDI Child Form est maximisée ou non. Il faut tester pour voir...

A BIENTÔT !!

Partager cet article

Commenter cet article