C#介面設計,添加無邊框表單的滑鼠拖動可以移動效果

來源:互聯網
上載者:User

標籤:檢測   動效   ccf   sem   無邊框   cat   epo   off   font   

開頭添加變數:


Point mouseOff;//滑鼠移動位置變數

bool leftFlag;//標籤是否為左鍵

 

事件部分:

 

 1  private void Login_MouseMove(object sender, MouseEventArgs e) 2         { 3             //滑鼠指向檢測 4             if (leftFlag) 5  6             { 7  8                 Point mouseSet = Control.MousePosition; 9 10                 mouseSet.Offset(mouseOff.X, mouseOff.Y);  //設定移動後的位置11 12                 Location = mouseSet;13 14             }15             //16         }17 18         private void Login_MouseUp(object sender, MouseEventArgs e)19         {20 21             if (leftFlag)22 23             {24 25                 leftFlag = false;//釋放滑鼠後標註為false;26 27             }28         }29 30         private void Login_MouseDown(object sender, MouseEventArgs e)31         {32             if (e.Button == MouseButtons.Left)33 34             {35 36                 mouseOff = new Point(-e.X, -e.Y); //得到變數的值37 38                 leftFlag = true;                  //點擊左鍵按下時標註為true;39 40             }41         }

ps:很常用的幾串字元。

  記住! 記住! 記住!

C#介面設計,添加無邊框表單的滑鼠拖動可以移動效果

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.