Пример #1
0
        protected override void WndProc(ref Message m)
        {
            IntPtr result = IntPtr.Zero;

            bool callDWP = !Win32Interop.DwmDefWindowProc(m.HWnd, m.Msg, m.WParam, m.LParam, out result);

            switch (m.Msg)
            {
            case Win32Messages.WM_CREATE:
            {
                RECT rc;
                int  style   = Win32Interop.GetWindowLong(m.HWnd, Win32Constants.GWL_STYLE);
                int  styleEx = Win32Interop.GetWindowLong(m.HWnd, Win32Constants.GWL_EXSTYLE);
                Win32Interop.AdjustWindowRectEx(out rc, style, false, styleEx);

                //BorderTop = Math.Abs(rc.top);
                //BorderLeft = Math.Abs(rc.left);
                BorderRight  = Math.Abs(rc.right);
                BorderBottom = Math.Abs(rc.bottom);
            }
            break;

            case Win32Messages.WM_ACTIVATE:
            {
                MARGINS margins = new MARGINS();

                margins.cxLeftWidth    = Math.Abs(BorderLeft);
                margins.cxRightWidth   = Math.Abs(BorderRight);
                margins.cyBottomHeight = Math.Abs(BorderBottom);
                margins.cyTopHeight    = Math.Abs(BorderTop);

                int hr = Win32Interop.DwmExtendFrameIntoClientArea(m.HWnd, ref margins);

                result = IntPtr.Zero;
            }
            break;

            case Win32Messages.WM_NCCALCSIZE:
            {
                if (m.WParam != IntPtr.Zero)
                {
                    result  = IntPtr.Zero;
                    callDWP = false;
                }
            }
            break;

            case Win32Messages.WM_NCHITTEST:
            {
                int ht = NCHitText(m);

                callDWP = (ht == Win32Constants.HTNOWHERE);
                result  = new IntPtr(ht);
            }
            break;
            }

            m.Result = result;
            if (callDWP)
            {
                base.WndProc(ref m);
            }
        }
Пример #2
0
 public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);