国产探花免费观看_亚洲丰满少妇自慰呻吟_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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 扶余县| 饶阳县| 济源市| 修文县| 攀枝花市| 汨罗市| 文登市| 凤山县| 专栏| 宁南县| 隆子县| 介休市| 富川| 连平县| 临邑县| 布尔津县| 南涧| 台山市| 军事| 丹巴县| 佳木斯市| 团风县| 台江县| 民勤县| 闵行区| 焦作市| 富源县| 兴宁市| 绍兴市| 平顺县| 刚察县| 株洲县| 涡阳县| 吉林市| 灵寿县| 厦门市| 牡丹江市| 合肥市| 龙游县| 余姚市| 东至县|