鼠标移动没有标题栏的winform窗口

昨天在做项目的时候想实现一下这个功能.也是在网上找了几种方法.挑了个比较简单的(我比较懒) ,效果还行,只是用了这个鼠标的其他事件都不管用了. 不知道要怎么解决这个问题

  private const int WM_NCHITTEST = 0x84;
  
private const int HTCLIENT = 0x1;
  
private const int HTCAPTION = 0x2

  
protected override void WndProc(ref Message m)
  
{
   
const int WM_NCHITTEST = 0x84;
   
const int HTCLIENT = 0x01;
   
const int HTCAPTION = 0x02;

   
if (m.Msg == WM_NCHITTEST)
   
{
    
this.DefWndProc(ref m);
    
if (m.Result.ToInt32() == HTCLIENT)
     m.Result 
= new IntPtr(HTCAPTION);
    
else
     
base.WndProc(ref m);
   }

   
else
    
base.WndProc(ref m);
  }


posted on 2006-10-28 10:36  散步的蠕虫  阅读(260)  评论(0编辑  收藏  举报

导航