国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

winfrom-繪制矩形并移動(dòng)

2019-11-11 06:28:47
字體:
供稿:網(wǎng)友

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(MouseEventArgs e)        {            base.OnMouseDown(e);            if (m_Rect.Contains(e.Location))            {                this.m_LastMSPoint = e.Location;                isMove = true;//注意要加在這里                Cursor = Cursors.SizeAll;            }            else            {                return;            }        }        protected override void OnMouseMove(MouseEventArgs e)        {            base.OnMouseMove(e);            if (e.Button != MouseButtons.Left)            {                return;            }            if (isMove == true)            {                this.label1.Text = m_LastMSPoint.X + "," + m_LastMSPoint.Y + " ; " + e.Location.X + "," + e.Location.Y;                this.m_Rect.Offset(e.Location.X - this.m_LastMSPoint.X, e.Location.Y - this.m_LastMSPoint.Y);                this.Invalidate();                this.m_LastMSPoint = e.Location;            }        }        protected override void OnMouseUp(MouseEventArgs e)        {            isMove = false;            Cursor = Cursors.Default;        }    }}


上一篇:VIM入門

下一篇:!算 24 (dfs)

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 通城县| 科技| 九台市| 共和县| 张家川| 白玉县| 杂多县| 肃南| 阳江市| 龙井市| 开鲁县| 县级市| 宝丰县| 隆安县| 应城市| 双柏县| 广宁县| 西华县| 五莲县| 宜黄县| 银川市| 兴山县| 石棉县| 安新县| 滁州市| 八宿县| 北辰区| 固安县| 德惠市| 黔西| 武定县| 乌苏市| 贡觉县| 英山县| 新巴尔虎左旗| 雅安市| 东光县| 冷水江市| 旅游| 康平县| 平罗县|