pigeon95efrei
Messages postés9Date d'inscriptionmardi 11 mai 2004StatutMembreDernière intervention 7 novembre 2007
-
26 mars 2007 à 01:22
pigeon95efrei
Messages postés9Date d'inscriptionmardi 11 mai 2004StatutMembreDernière intervention 7 novembre 2007
-
27 mars 2007 à 12:17
Bonjour j'ai un probleme avec wndproc pour intercepter les evenements. Quand j'ai un formulaire vierge, tout fonctionne niquel!
Mais quand je lui ajoute un bouton par exemple. Plus rien ne fonctionne. Je comprends pas.
Voilà ma source;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace csTempWindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private int iChar;
private System.Windows.Forms.Button button1;
// Constant value was found in the "windows.h" header file.
public Form1()
{
InitializeComponent();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
}
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(48, 48);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.ResumeLayout(false);
}
protected override void WndProc(ref Message m)
{
if (m.Msg != WM_KEYDOWN)
{
base.WndProc(ref m);
}
else
{MessageBox.Show("1");
iChar = m.WParam.ToInt32();
switch(iChar)
{
case (int)Keys.D0:
this.button1.Text="1";
break;
case (int)Keys.D1:
MessageBox.Show("1");
break;
case (int)Keys.D2:
MessageBox.Show("2");
break;
default:
//Make sure that you pass unhandled messages back to the default message handler.
base.WndProc(ref m);
break;