很簡單的幾行代碼
this.FormBorderStyle = FormBorderStyle.None; //設置窗體為無邊框樣式 this.WindowState = FormWindowState.Maximized; //最大化窗體 this.TopMost = true; //設置窗體置頂
始終獲取焦點
//調用API [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, ExactSpelling = true)] public static extern IntPtr GetForegroundWindow(); //獲得本窗體的句柄 [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "SetForegroundWindow")] public static extern bool SetForegroundWindow(IntPtr hWnd);//設置此窗體為活動窗體 //定義變量,句柄類型 public IntPtr Handle1; public Form1() { InitializeComponent(); // this.FormBorderStyle = FormBorderStyle.None; //設置窗體為無邊框樣式 // this.WindowState = FormWindowState.Maximized; //最大化窗體 this.TopMost = true; //設置窗體置頂 } private void Form1_Load(object sender, EventArgs e) { Handle1 = this.Handle; } private void timer1_Tick(object sender, EventArgs e) { //設置此窗體為活動窗體 SetForegroundWindow(Handle1); }