国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 诸暨市| 田林县| 海南省| 罗定市| 香格里拉县| 宕昌县| 周至县| 沙洋县| 巴马| 阜平县| 隆安县| 永兴县| 贵阳市| 石阡县| 琼海市| 陆川县| 德昌县| 衡阳市| 胶南市| 安庆市| 阿鲁科尔沁旗| 长顺县| 阜康市| 蒙阴县| 西和县| 藁城市| 吉安市| 木里| 莒南县| 溧水县| 电白县| 涪陵区| 兴海县| 高尔夫| 建昌县| 天峻县| 门源| 繁昌县| 越西县| 宁强县| 海淀区|