C#实现将窗体固定在显示器的左上角且不能移动的方法
来源:本站原创|时间:2022-11-25|栏目: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#程序设计有所帮助。
您可能感兴趣的文章
- 01-10C#通过反射获取当前工程中所有窗体并打开的方法
- 01-10WinForm限制窗体不能移到屏幕外的方法
- 01-10WinForm绘制圆角的方法
- 01-10C#实现txt定位指定行完整实例
- 01-10C#停止线程的方法
- 01-10WinForm实现仿视频 器左下角滚动新闻效果的方法
- 01-10C#实现清空回收站的方法
- 01-10C#实现读取注册表监控当前操作系统已安装软件变化的方法
- 01-10C#实现多线程下载文件的方法
- 01-10C#实现Winform中打开网页页面的方法