C# wm_nchisttest(无标题窗体的移动方法)

来源:互联网 发布:华泰证券mac版软件 编辑:程序博客网 时间:2024/05/14 10:54
    protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case 0x0084: //如果鼠标移动或单击                 
                    base.WndProc(ref m);//调用基类的窗口过程——WndProc方法处理这个消息
                    if (m.Result == (IntPtr)1)//如果返回的是HTCLIENT
                    {
                        m.Result = (IntPtr)2;//把它改为HTCAPTION
                        return;//直接返回退出方法
                    }
                    break;
            }
            base.WndProc(ref m);//如果不是鼠标移动或单击消息就调用基类的窗口过程进行处理

        }


wpf  的wndproc

    private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
            if (source != null) source.AddHook(WndProc);
        }


        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            
        }

0 0
原创粉丝点击