using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Frm : Form
{
private bool G_OnMouseDown;
private Graphics g;
private Pen pen = new Pen(Color.Blue, 5);
private Point CPoint;
Point lastPoint;
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "ShowCursor")]
public static extern bool ShowCursor(bool bShow);
private void Frm_MouseMove(object sender, MouseEventArgs e)
{
if (lastPoint.Equals(Point.Empty))
{
lastPoint = new Point(e.X, e.Y);
}
if (G_OnMouseDown)
{
g = CreateGraphics();
CPoint = new Point(e.X, e.Y);
g.DrawLine(pen, CPoint, lastPoint);
}
lastPoint = new Point(e.X, e.Y);
}
private void Frm_MouseDown(object sender, MouseEventArgs e)
{
G_OnMouseDown = true;
}
private void Frm_MouseUp(object sender, MouseEventArgs e)
{
G_OnMouseDown = false;
}
public Frm()
{
InitializeComponent();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Frm : Form
{
private bool G_OnMouseDown;
private Graphics g;
private Pen pen = new Pen(Color.Blue, 5);
private Point CPoint;
Point lastPoint;
[System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "ShowCursor")]
public static extern bool ShowCursor(bool bShow);
private void Frm_MouseMove(object sender, MouseEventArgs e)
{
if (lastPoint.Equals(Point.Empty))
{
lastPoint = new Point(e.X, e.Y);
}
if (G_OnMouseDown)
{
g = CreateGraphics();
CPoint = new Point(e.X, e.Y);
g.DrawLine(pen, CPoint, lastPoint);
}
lastPoint = new Point(e.X, e.Y);
}
private void Frm_MouseDown(object sender, MouseEventArgs e)
{
G_OnMouseDown = true;
}
private void Frm_MouseUp(object sender, MouseEventArgs e)
{
G_OnMouseDown = false;
}
public Frm()
{
InitializeComponent();
}
}
}