本文實例講述了C#實現將窗體固定在顯示器的左上角且不能移動的方法。分享給大家供大家參考。具體實現方法如下:
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Runtime.InteropServices;namespace App{ public partial class Form4 : Form { public Form4() { InitializeComponent(); this.StartPosition = FormStartPosition.Manual; this.Location = new Point(0, 0); } protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == 0x84 && m.Result == (IntPtr)2) //不讓拖動標題欄 { m.Result = (IntPtr)1; } if (m.Msg == 0xA3) //雙擊標題欄無反應 { m.WParam = System.IntPtr.Zero; } } }}
希望本文所述對大家的C#程序設計有所幫助。
新聞熱點
疑難解答