C#實現將窗體固定在顯示器的左上角且不能移動的方法
更新時間:2015年08月25日 12:22:33 作者:我心依舊
這篇文章主要介紹了C#實現將窗體固定在顯示器的左上角且不能移動的方法,涉及C#窗體固定操作的相關技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了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#程序設計有所幫助。
相關文章
在C#中List集合使用First()方法獲取第一個元素的操作
這篇文章主要介紹了在C#中List集合使用First()方法獲取第一個元素的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-12-12

