コード例 #1
0
ファイル: AlBaseForm.cs プロジェクト: shi-tou/EmailTool
        private void WM_NCHITTEST(ref Message m)
        {
            int   wparam = m.LParam.ToInt32();
            Point point  = new Point(Win32.LOWORD(wparam), Win32.HIWORD(wparam));

            point = PointToClient(point);
            if (_IsResize)
            {
                if (point.X <= 8)
                {
                    if (point.Y <= 8)
                    {
                        m.Result = (IntPtr)Win32.HTTOPLEFT;
                    }
                    else if (point.Y > Height - 8)
                    {
                        m.Result = (IntPtr)Win32.HTBOTTOMLEFT;
                    }
                    else
                    {
                        m.Result = (IntPtr)Win32.HTLEFT;
                    }
                }
                else if (point.X >= Width - 8)
                {
                    if (point.Y <= 8)
                    {
                        m.Result = (IntPtr)Win32.HTTOPRIGHT;
                    }
                    else if (point.Y >= Height - 8)
                    {
                        m.Result = (IntPtr)Win32.HTBOTTOMRIGHT;
                    }
                    else
                    {
                        m.Result = (IntPtr)Win32.HTRIGHT;
                    }
                }
                else if (point.Y <= 8)
                {
                    m.Result = (IntPtr)Win32.HTTOP;
                }
                else if (point.Y >= Height - 8)
                {
                    m.Result = (IntPtr)Win32.HTBOTTOM;
                }
                else
                {
                    m.Result = (IntPtr)Win32.HTCAPTION;
                }
            }
            else
            {
                m.Result = (IntPtr)Win32.HTCAPTION;
            }
        }
コード例 #2
0
ファイル: AlBaseForm.cs プロジェクト: freedebug/xcode
        // 处理拖动窗体时,是否允许最大化或者最小化的判断
        private void WM_NCHITTEST(ref Message m)
        {
            int   wparam = m.LParam.ToInt32();
            Point point  = new Point(Win32.LOWORD(wparam), Win32.HIWORD(wparam));

            point = PointToClient(point);

            /*
             * 此段代码的用处是:对于MaximizeBox为True的窗口,可以通过拉动窗体边缘缩放窗体
             * 此处将此段代码屏蔽,让所有的窗体都不能随意缩放
             */
            //if (this.MaximizeBox)
            //{
            //    if (point.X <= 8)
            //    {
            //        if (point.Y <= 8)
            //            m.Result = (IntPtr)Win32.HTTOPLEFT;
            //        else if (point.Y > Height - 8)
            //            m.Result = (IntPtr)Win32.HTBOTTOMLEFT;
            //        else
            //            m.Result = (IntPtr)Win32.HTLEFT;
            //    }
            //    else if (point.X >= Width - 8)
            //    {
            //        if (point.Y <= 8)
            //            m.Result = (IntPtr)Win32.HTTOPRIGHT;
            //        else if (point.Y >= Height - 8)
            //            m.Result = (IntPtr)Win32.HTBOTTOMRIGHT;
            //        else
            //            m.Result = (IntPtr)Win32.HTRIGHT;
            //    }
            //    else if (point.Y <= 8)
            //    {
            //        m.Result = (IntPtr)Win32.HTTOP;
            //    }
            //    else if (point.Y >= Height - 8)
            //        m.Result = (IntPtr)Win32.HTBOTTOM;
            //    else
            //        m.Result = (IntPtr)Win32.HTCAPTION;
            //}
            //else
            //{ m.Result = (IntPtr)Win32.HTCAPTION; }
            m.Result = (IntPtr)Win32.HTCAPTION;
        }