现在的位置: 首页 > 综合 > 正文

不让拖动的标题栏, 双击标题栏无反应

2012年12月16日 ⁄ 综合 ⁄ 共 691字 ⁄ 字号 评论关闭
 1using System;
 2using System.Windows.Forms;
 3
 4public class Test : Form
 5{
 6  Test()
 7  {
 8    Text            = "不让拖动的标题栏, 双击标题栏无反应";
 9    FormBorderStyle = FormBorderStyle.FixedDialog;
10    MaximizeBox     = false;
11    MinimizeBox     = false;
12  }

13
14  protected override void WndProc(ref Message m)
15  {
16    base.WndProc(ref m);
17    if(m.Msg == 0x84 && m.Result == (IntPtr)2// 不让拖动标题栏
18    {
19      m.Result = (IntPtr)1;
20    }

21    if (m.Msg == 0xA3)                         // 双击标题栏无反应
22    {
23      m.WParam = System.IntPtr.Zero;
24    }

25  }

26
27  static void Main()
28  {
29    Application.Run(new Test());
30  }

31}

从CSDN论坛上看来的,遗憾的是还可以在标题栏上点右键来移动窗口,应该也是可以禁止的,但我对WndProc不熟悉,不知道该怎么实现。

抱歉!评论已关闭.