您好,登錄后才能下訂單哦!
這篇文章給大家介紹C#中怎么實現一個無邊框窗體,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
代碼:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace NoBorderForm { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } Point mouseOff;//鼠標移動位置變量 bool leftFlag;//標記是否為左鍵 private void Form1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mouseOff = new Point(-e.X, -e.Y); //得到變量的值 leftFlag = true; //點擊左鍵按下時標注為true; } } private void Form1_MouseMove(object sender, MouseEventArgs e) { if (leftFlag) { Point mouseSet = Control.MousePosition; mouseSet.Offset(mouseOff.X, mouseOff.Y); //設置移動后的位置 Location = mouseSet; } } private void Form1_MouseUp(object sender, MouseEventArgs e) { if (leftFlag) { leftFlag = false;//釋放鼠標后標注為false; } } private void button1_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("yes/no", "exit", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dr == DialogResult.Yes) { this.Close(); } else { return; } } private void button2_Click(object sender, EventArgs e) { this.WindowState = FormWindowState.Minimized; } private void checkBox1_CheckedChanged(object sender, EventArgs e) { } private void Form1_Click(object sender, EventArgs e) { } private void panel1_Click(object sender, EventArgs e) { } private void textBox1_Click(object sender, EventArgs e) { } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { System.Diagnostics.Process.Start("http://www.baidu.com"); } private void button4_Click(object sender, EventArgs e) { } } }
關于C#中怎么實現一個無邊框窗體就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。