mousemove problem...

Hello,

i have an application with signature form...

public partial class Form1 : Form

{

private Bitmap bitmap;

private bool hasCapture;

private int oldX = 0;

private int oldY = 0;

private Pen ipen = new Pen(Color.Red);

public Form1()

{

InitializeComponent();

}

private void panel1_Paint(object sender, PaintEventArgs e)

{

e.Graphics.DrawImage(this.bitmap, 0, 0 );

}

private void panel1_MouseDown(object sender, MouseEventArgs e)

{

hasCapture = true;

oldX = e.X;

oldY = e.Y;

}

private void panel1_MouseMove(object sender, MouseEventArgs e)

{

int x, y;

if (hasCapture)

{

x = e.X;

y = e.Y;

Graphics.FromImage(bitmap).DrawLine(ipen, oldX, oldY, x, y);

panel1.Invalidate(new Rectangle(Math.Min(x, oldX), Math.Min(y, oldY), Math.Abs(oldX - x) + 1, Math.Abs(oldY - y) + 1));

oldX = x;

oldY = y;

}

}

private void panel1_MouseUp(object sender, MouseEventArgs e)

{

hasCapture = false;

}

private void Form1_Load(object sender, EventArgs e)

{

bitmap = new Bitmap(240, 147, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

Graphics.FromImage(bitmap).Clear(Color.White);

this.firmaTableAdapter.Fill(this.firmaDataSet.Firma);

}

private void button1_Click(object sender, EventArgs e)

{

FirmaDataSet.FirmaRow fr = firmaDataSet.Firma.NewFirmaRow();

fr["firma"] = ConvertImageToByteArray(bitmap, System.Drawing.Imaging.ImageFormat.Bmp);

firmaDataSet.Firma.Rows.Add(fr);

firmaTableAdapter.Update(firmaDataSet.Firma);

}

private byte[] ConvertImageToByteArray(System.Drawing.Bitmap imageToConvert, System.Drawing.Imaging.ImageFormat formatOfImage)

{

byte[] Ret;

try

{

using (System.IO.MemoryStream ms = new System.IO.MemoryStream())

{

imageToConvert.Save(ms, formatOfImage);

Ret = ms.ToArray();

}

}

catch (Exception ex) { throw; }

return Ret;

}

}

but i have a problem, in some PPC it works good and in some it doesnt work...

i have found that the mousemove only fires when the mouse button is released... someone solved this problem

thanks!



Answer this question

mousemove problem...

  • mtm81

    neither...

    do not work...

  • shmulik_segal

    Try adding panel1.Capture = true to the MouseDown event and panel1.Capture = false to the MouseUp event...


  • mousemove problem...