In your Form constructor (after the InitializeComponent(); call), add:
monitor.MouseMove += new MouseEventHandler(monitor_MouseMove);
monitor.MouseLeave += new EventHandler(monitor_MouseLeave);
monitor.MouseClick += new MouseEventHandler(monitor_MouseClick);
Now add the following to your Form class:
const int adjustX = -50;
const int adjustY = -50;
public Size boxSize = new Size(100, 100);
public int lastX = 2 * adjustX;
public int lastY = 2 * adjustY;
private void monitor_MouseMove(object sender, MouseEventArgs e) {
if (e.X != lastX || e.Y != lastY) {
Graphics g = monitor.CreateGraphics();
g.CopyFromScreen(monitor.PointToScreen(new Point(lastX + adjustX, lastY + adjustY)), new Point(lastX + adjustX, lastY + adjustY), boxSize, CopyPixelOperation.DestinationInvert);
lastX = e.X;
lastY = e.Y;
g.CopyFromScreen(monitor.PointToScreen(new Point(e.X + adjustX, e.Y + adjustY)), new Point(e.X + adjustX, e.Y + adjustY), boxSize, CopyPixelOperation.DestinationInvert);
}
}
void monitor_MouseLeave(object sender, EventArgs e) {
Graphics g = monitor.CreateGraphics();
g.CopyFromScreen(monitor.PointToScreen(new Point(lastX + adjustX, lastY + adjustY)), new Point(lastX + adjustX, lastY + adjustY), boxSize, CopyPixelOperation.DestinationInvert);
lastX = 2 * adjustX;
lastY = 2 * adjustY;
}
Finally, in your mouse click handler:
void monitor_MouseClick(object sender, MouseEventArgs e) {
}
You will have to add whatever you want done with the selected area. You could copy it to another picture box, save it as a bitmap, whatever.