Ejemplo n.º 1
0
 private void WmCalcSize(ref Message m)
 {
     base.DefWndProc(ref m);
     if (m.WParam == IntPtr.Zero)
     {
         Win32.RECT rct = (Win32.RECT)m.GetLParam(typeof(Win32.RECT));
         //get new clientsize
         this.OnCalcSize(ref rct);
         Marshal.StructureToPtr(rct, m.LParam, true);
     }
     else
     {
         Win32.NCCALCSIZE_PARAMS calc =
             (Win32.NCCALCSIZE_PARAMS)m.GetLParam(typeof(Win32.NCCALCSIZE_PARAMS));
         //get new clientsize
         this.OnCalcSize(ref calc.newbounds);
         Marshal.StructureToPtr(calc, m.LParam, true);
     }
     m.Result = new IntPtr(Win32.WVR_REDRAW);
 }
Ejemplo n.º 2
0
        protected override void WndProc(ref Message m)
        {
            if (IsApply == false)
            {
                base.WndProc(ref m);
                return;
            }
            if (m.Msg == Win32.WM_NCCREATE)
            {
                Win32.CREATESTRUCT userdata = (Win32.CREATESTRUCT)Marshal.PtrToStructure(m.LParam, typeof(Win32.CREATESTRUCT));

                // store window instance pointer in window user data
                Win32.SetWindowLongPtr(new HandleRef(this, m.HWnd), Win32.GWLP_USERDATA, userdata.lpCreateParams);
            }
            switch (m.Msg)
            {
            case Win32.WM_NCCALCSIZE:
            {
                if ((int)m.WParam == 1 && borderless)
                {
                    Win32.NCCALCSIZE_PARAMS param = (Win32.NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(Win32.NCCALCSIZE_PARAMS));
                    adjust_maximized_client_rect(Handle, param.rgrc[0]);
                    m.Result = IntPtr.Zero;
                    return;
                }
                break;
            }

            case Win32.WM_NCHITTEST:
            {
                // When we have no border or title bar, we need to perform our
                // own hit testing to allow resizing and moving.
                if (borderless)
                {
                    m.Result = (IntPtr)hit_test(new Point((int)m.LParam));
                    return;
                }
                break;
            }

            case Win32.WM_NCACTIVATE:
            {
                if (!composition_enabled())
                {
                    // Prevents window frame reappearing on window activation
                    // in "basic" theme, where no aero shadow is present.
                    m.Result = (IntPtr)1;
                    return;
                }
                break;
            }

                //case Win32.WM_CLOSE:
                //    {
                //        //  Close();
                //        Win32.DestroyWindow(Handle);
                //        m.Result = IntPtr.Zero;
                //        return;
                //    }

                //case Win32.WM_DESTROY:
                //    {
                //        Environment.Exit(0);
                //        m.Result = IntPtr.Zero;
                //        return;
                //    }

                //case Win32.WM_KEYDOWN:
                //case Win32.WM_SYSKEYDOWN:
                //    {
                //        switch ((int)m.WParam)
                //        {
                //            case Win32.VK_F8: { borderless_drag = !borderless_drag; m.Result = IntPtr.Zero; return; }
                //            case Win32.VK_F9: { borderless_resize = !borderless_resize; m.Result = IntPtr.Zero; return; }
                //            case Win32.VK_F10: { set_borderless(!borderless); m.Result = IntPtr.Zero; return; }
                //            case Win32.VK_F11: { set_borderless_shadow(!borderless_shadow); m.Result = IntPtr.Zero; return; }
                //        }
                //        break;
                //    }
            }
            base.WndProc(ref m);
        }