Salut à tous,
Je bosse sur un projet C#/VS 2005 express en mode MDI.
Je souhaite passer d'un formulaire à l'autre en pressant la touche F12 (changer le focus d'un MDIchildren), pour cela j'ai tenter deux approches et aucune ne marche. Je vois bien qu'avec le debugueur l'application ne déclenche jamais les événements. Je n'y comprends rien du tout. En voici le code :
Merci pour votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 // dans InitializeComponents() this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainMenu_KeyUp); private void MainMenu_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.F12) { if (this.MdiChildren.Length > 0) { if (this.iNavMdiChildren >=this.MdiChildren.Length - 1) this.iNavMdiChildren = 0; else this.iNavMdiChildren++; this.MdiChildren[this.iNavMdiChildren].Focus(); } } } protected override void OnKeyPress(KeyPressEventArgs e) { base.OnKeyPress(e); if ((int)e.KeyChar == (int)Keys.Escape) { this.Close(); } if ((int)e.KeyChar == (int)Keys.F12) { if (this.MdiChildren.Length > 0) { if (this.iNavMdiChildren >= this.MdiChildren.Length - 1) this.iNavMdiChildren = 0; else this.iNavMdiChildren++; this.MdiChildren[this.iNavMdiChildren].Focus(); } } }
Partager