MouseMove event does not work on Windows 10 for transparent PictureBox

  • Thread starter Thread starter BorisM
  • Start date Start date
B

BorisM

Guest
Simple sample: Winform with TransparencyKey set to a specific color, say magenta. PictureBox is placed over client area of the form and its BackColor is set to the same magenta.

Add events:

private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Pen pen = new Pen(Color.Red, 4);
e.Graphics.DrawLine(pen, 50,50, 500,500);
}

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.X > 50 && e.Y > 50)
Cursor = Cursors.Cross;
}

This sample works fine on Windows 7: red line is drawn on a transparent area. When you move a mouse over the line, cursor is changed to the cross. A breakpoint in the body of pictureBox1_MouseMove get hit

On Windows 10, the breakpoint is never hit and cursor is never changed.

Is this a bug? Any suggestions how to work around it?

Thanks!

Continue reading...
 
Back
Top