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

首頁 > 學院 > 開發設計 > 正文

winfrom-繪制矩形并移動

2019-11-11 05:17:15
字體:
來源:轉載
供稿:網友

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;        }    }}


上一篇:bean的生命周期

下一篇:凌亂的yyy

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泸溪县| 蒲江县| 北安市| 高邑县| 神农架林区| 绥滨县| 甘泉县| 桐梓县| 旬阳县| 绥江县| 龙泉市| 临海市| 达州市| 成安县| 丰镇市| 阜宁县| 梅州市| 招远市| 中宁县| 松桃| 济阳县| 滨州市| 江西省| 新余市| 阿克陶县| 襄樊市| 蚌埠市| 晋中市| 防城港市| 桑植县| 读书| 札达县| 商水县| 甘南县| 天峻县| 马公市| 梁山县| 康定县| 民权县| 乃东县| 慈溪市|