using System;
using System.Drawing;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class ang : Form
{
bool isMove = false;
private Rectangle m_Rect;
private Point m_LastMSPoint;
public ang()
{
InitializeComponent();
DoubleBuffered = true;
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
m_Rect = new Rectangle(10, 10, 50, 30);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(SystemBrushes.ControlDark, this.m_Rect);
e.Graphics.DrawRectangle(SystemPens.ControlDarkDark, this.m_Rect);
//Rectangle r = e.ClipRectangle;
//this.label1.Text = r.X + "," + r.Y;
}
protected override void OnMouseDown(M
winfrom-绘制矩形并移动
最新推荐文章于 2024-08-22 17:57:11 发布
本文介绍了如何在Windows窗体应用程序中利用GDI+绘制矩形,并实现矩形的动态移动,详细阐述了绘制过程和鼠标事件处理技巧。
摘要由CSDN通过智能技术生成