I want to make a drawing application that runs on top of the screen, providing a layer of a transparent canvas on top of the screen that can be painted. So it's like drawing directly on the screen when in fact it is not.
I've made a drawing application, and it works very well. Using a borderless form so as to cover all areas of the screen. Using mouse events (MOUSE_DOWN, MOUSE_MOVE, MOUSE_UP) for the drawing process. And Using the PictureBox (pbxCanvas) as Canvas.
But when I change TransparancyKey of the form to white, the same color as the background canvas (which is actually a general color in bitmap bCanvas), Mouse clicks become pass through form and I can not draw on the canvas.
**Note**
This event is a mouse that I use to draw:
I've made a drawing application, and it works very well. Using a borderless form so as to cover all areas of the screen. Using mouse events (MOUSE_DOWN, MOUSE_MOVE, MOUSE_UP) for the drawing process. And Using the PictureBox (pbxCanvas) as Canvas.
But when I change TransparancyKey of the form to white, the same color as the background canvas (which is actually a general color in bitmap bCanvas), Mouse clicks become pass through form and I can not draw on the canvas.
TransparencyKey = Color.White;is there any way that I can achieve this? use mouse events to draw on a transparent canvas, and can save the image created in a bitmap file, without making significant changes in a drawing application that I have created.
**Note**
This event is a mouse that I use to draw:
#region Draw to pbxCanvas
public void Draw(bool draw, Point sp, Point ep)
{
if (draw)
{
gCanvas.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
pen = new Pen(new SolidBrush(ColorName), BrushSize);
if (toolPen.Checked)
{
gCanvas.DrawLine(pen, sp, ep);
}
else if (toolEreser.Checked)
{
Rectangle rect = new Rectangle(ep.X, ep.Y, BrushSize*5, BrushSize*5);
gCanvas.DrawEllipse(pen, rect);
gCanvas.FillEllipse(new SolidBrush(ColorName), rect);
}
pbxCanvas.Refresh();
dirty = true;
}
}
private void pbxCanvas_MouseDown(object sender, MouseEventArgs e)
{
sp = e.Location;
if (e.Button == MouseButtons.Left)
{
ActivePaint = true;
}
}
private void pbxCanvas_MouseUp(object sender, MouseEventArgs e)
{
ActivePaint = false;
}
private void pbxCanvas_MouseMove(object sender, MouseEventArgs e)
{
ep = e.Location;
Draw(ActivePaint, sp, ep);
sp = ep;
}
#endregion
***Note***: This is WinForm Application.