• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            cc

              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              38 隨筆 :: 14 文章 :: 21 評(píng)論 :: 0 Trackbacks

            方法一: 窗體或者控件的拖動(dòng)

               private Point m_MousePoint;
            private Point m_LastPoint;

              protected override void OnMouseDown(MouseEventArgs e)
            {
            base.OnMouseDown(e);
            this.m_LastPoint = this.Location;
            this.m_MousePoint = this.PointToScreen(e.Location);
            }


            protected override void OnMouseMove(MouseEventArgs e)
            {
            base.OnMouseMove(e);
            if (e.Button == MouseButtons.Left)
            {
            Point t = this.PointToScreen(e.Location);
            Point l = this.m_LastPoint;

                    l.Offset(t.X - this.m_MousePoint.X, t.Y - this.m_MousePoint.Y);
            this.Location = l;
            }
            }

            1 代碼直接復(fù)制到窗體上就可以使用.

            2 可以用到UserControl上,UserControl就成了一個(gè)可拖動(dòng)的控件了

            3 可以用到自定義控件上,例如:自定義控件繼承了一個(gè)Button ,然后寫(xiě)上上面代碼,那么這個(gè)自定義Button就可以在Form窗體上隨處拖動(dòng)....

             方法二: 不規(guī)則窗體拖動(dòng)

            using System.Runtime.InteropServices;

            [DllImport("user32.dll")]
            public static extern bool ReleaseCapture();
            [DllImport("user32.dll")]
            public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
            public const int WM_SYSCOMMAND = 0x0112;
            public const int SC_MOVE = 0xF010;
            public const int HTCAPTION = 0x0002;

            public void ShapedForm_MouseDown(object sender, MouseEventArgs e)
            {
            ReleaseCapture();
            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
            }


            方法二:比較好 ,能夠畫(huà)出 虛線框,跟Windows的窗體拖動(dòng)一樣...........

            posted on 2010-01-27 10:30 醒目西西 閱讀(2432) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            少妇被又大又粗又爽毛片久久黑人| 亚洲?V乱码久久精品蜜桃| 热RE99久久精品国产66热| 久久91精品国产91久| 99久久无码一区人妻a黑| 国产精品美女久久久网AV| 久久99精品国产自在现线小黄鸭| 久久99国产精品二区不卡| 国产色综合久久无码有码| 久久精品无码免费不卡| 狠狠色婷婷久久一区二区| 久久婷婷五月综合97色直播| 秋霞久久国产精品电影院| 国产偷久久久精品专区| 狠狠综合久久综合88亚洲 | 97久久综合精品久久久综合| 亚洲国产日韩欧美综合久久| 亚洲国产天堂久久综合| 无码任你躁久久久久久| 亚洲AV伊人久久青青草原| 久久久久综合国产欧美一区二区| 青青草国产精品久久久久| 久久综合亚洲欧美成人| 精品人妻伦九区久久AAA片69| 狠狠色丁香久久婷婷综合五月| 久久亚洲中文字幕精品一区| 91精品国产91久久久久福利| 久久久久久国产精品免费免费| 亚洲色欲久久久久综合网| 久久久一本精品99久久精品88| 国产婷婷成人久久Av免费高清| 久久国产精品免费| 久久精品人人做人人爽电影蜜月| 久久久久一区二区三区| 中文字幕亚洲综合久久菠萝蜜| 久久影院综合精品| 亚洲综合伊人久久综合| 亚洲国产高清精品线久久 | 婷婷久久五月天| 亚洲中文字幕久久精品无码APP | 精品国产青草久久久久福利|