您好,登錄后才能下訂單哦!
這篇文章給大家介紹C#中怎么實(shí)現(xiàn)一個(gè)無邊框窗體,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
代碼:
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;//鼠標(biāo)移動(dòng)位置變量 bool leftFlag;//標(biāo)記是否為左鍵 private void Form1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { mouseOff = new Point(-e.X, -e.Y); //得到變量的值 leftFlag = true; //點(diǎn)擊左鍵按下時(shí)標(biāo)注為true; } } private void Form1_MouseMove(object sender, MouseEventArgs e) { if (leftFlag) { Point mouseSet = Control.MousePosition; mouseSet.Offset(mouseOff.X, mouseOff.Y); //設(shè)置移動(dòng)后的位置 Location = mouseSet; } } private void Form1_MouseUp(object sender, MouseEventArgs e) { if (leftFlag) { leftFlag = false;//釋放鼠標(biāo)后標(biāo)注為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) { } } }
關(guān)于C#中怎么實(shí)現(xiàn)一個(gè)無邊框窗體就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。