Esempio n. 1
0
 public ShapedForm()
 {
     if (ShapedForm.dllWrapper == null)
     {
         ShapedForm.dllWrapper = new DllWrapper("dwmapi.dll");
         if (ShapedForm.dllWrapper.IsDllLoaded)
         {
             ShapedForm.dwmIsCompositionEnabled = (ShapedForm.DwmIsCompositionEnabled)ShapedForm.dllWrapper.GetFunctionAsDelegate("DwmIsCompositionEnabled", typeof(ShapedForm.DwmIsCompositionEnabled));
             if (ShapedForm.dwmIsCompositionEnabled != null)
             {
                 bool isEnabled = false;
                 int  num       = ShapedForm.dwmIsCompositionEnabled(ref isEnabled);
                 if (isEnabled)
                 {
                     ShapedForm.dwmEnableBlurBehindWindow = (ShapedForm.DwmEnableBlurBehindWindow)ShapedForm.dllWrapper.GetFunctionAsDelegate("DwmEnableBlurBehindWindow", typeof(ShapedForm.DwmEnableBlurBehindWindow));
                     ShapedForm.isCompositionAvailable    = true;
                 }
             }
         }
     }
     this.InitializeComponent();
 }
Esempio n. 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!this.DesignMode && this.enableCompositionOnVista && ShapedForm.isCompositionAvailable)
            {
                Telerik.WinControls.NativeMethods.SetLayeredWindowAttributes(new HandleRef((object)this, this.Handle), 100, (byte)0, 1);
                ShapedForm.dwmEnableBlurBehindWindow(this.Handle, ref new Telerik.WinControls.NativeMethods.DWM_BLURBEHIND()
                {
                    dwFlags = 5U,
                    fEnable = true,
                    fTransitionOnMaximized = false
                });
                ThemeResolutionService.ApplicationThemeChanged += new ThemeChangedHandler(this.ApplicationThemeChanged);
            }
            if (!TelerikHelper.IsWindows8OrLower && !TelerikHelper.IsWindows10CreatorsUpdateOrHigher)
            {
                return;
            }
            SizeF monitorDpi = Telerik.WinControls.NativeMethods.GetMonitorDpi(Screen.FromControl((Control)this), Telerik.WinControls.NativeMethods.DpiType.Effective);

            this.oldDpi     = this.currentDpi;
            this.currentDpi = (int)Math.Round((double)monitorDpi.Width * 96.0, MidpointRounding.AwayFromZero);
            this.HandleDpiChanged();
        }
Esempio n. 3
0
        public virtual void HandleMouseMove(MouseEventArgs e, Form form)
        {
            //fix allow resize when form is not sizeble
            ShapedForm shapedForm            = form as ShapedForm;
            bool       parentFormAllowResize = true;

            if (shapedForm != null)
            {
                parentFormAllowResize = shapedForm.AllowResize;
            }

            if (form.WindowState == FormWindowState.Normal)
            {
                if (e.Button == MouseButtons.Left && downPoint != e.Location)
                {
                    //p.p. 28.08.07
                    //add resize support to titlebar
                    NativeMethods.ReleaseCapture();
                    if (parentFormAllowResize && this.allowResize)
                    {
                        if (e.Y >= 0 && e.Y < 7)
                        {
                            if (e.X < 7)
                            {
                                Cursor.Current = Cursors.SizeNWSE;
                                NativeMethods.SendMessage(new HandleRef(this, form.Handle), NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTTOPLEFT, IntPtr.Zero);
                            }
                            else if (e.X > (this.Size.Width - 7))
                            {
                                Cursor.Current = Cursors.SizeNESW;
                                NativeMethods.SendMessage(new HandleRef(this, form.Handle), NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTTOPRIGHT, IntPtr.Zero);
                            }
                            else
                            {
                                Cursor.Current = Cursors.SizeNS;
                                NativeMethods.SendMessage(new HandleRef(this, form.Handle), NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTTOP, IntPtr.Zero);
                            }
                        }
                        else if (e.X < 7)
                        {
                            Cursor.Current = Cursors.SizeWE;
                            NativeMethods.SendMessage(new HandleRef(this, form.Handle), NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTLEFT, IntPtr.Zero);
                        }
                        else if (e.X > (this.Size.Width - 7))
                        {
                            Cursor.Current = Cursors.SizeWE;
                            NativeMethods.SendMessage(new HandleRef(this, form.Handle), NativeMethods.WM_NCLBUTTONDOWN, NativeMethods.HTRIGHT, IntPtr.Zero);
                        }
                        //end add
                    }
                    if (this.canManageOwnerForm && e.X < this.Size.Width - this.systemButtons.Size.Width)
                    {
                        NativeMethods.SendMessage(new HandleRef(this, form.Handle), NativeMethods.WM_NCLBUTTONDOWN, 2, IntPtr.Zero);
                    }
                }
                else
                {
                    if (allowResize)
                    {
                        if (e.Y >= 0 && e.Y < 4)
                        {
                            Cursor.Current = Cursors.SizeNS;
                            if (e.X < 7)
                            {
                                Cursor.Current = Cursors.SizeNWSE;
                            }
                            else if (e.X > (this.Size.Width - 7))
                            {
                                Cursor.Current = Cursors.SizeNESW;
                            }
                            else
                            {
                                Cursor.Current = Cursors.SizeNS;
                            }
                        }
                        else if (e.X < 7)
                        {
                            Cursor.Current = Cursors.SizeWE;
                        }
                        else if (e.X > (this.Size.Width - 7))
                        {
                            Cursor.Current = Cursors.SizeWE;
                        }
                        else
                        {
                            Cursor.Current = Cursors.Default;
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public virtual void HandleMouseMove(MouseEventArgs e, Form form)
        {
            ShapedForm shapedForm = form as ShapedForm;
            bool       flag       = true;

            if (shapedForm != null)
            {
                flag = shapedForm.AllowResize;
            }
            if (form.WindowState != FormWindowState.Normal && form.WindowState != FormWindowState.Maximized)
            {
                return;
            }
            if (e.Button == MouseButtons.Left && this.downPoint != e.Location)
            {
                Telerik.WinControls.NativeMethods.ReleaseCapture();
                if (flag && this.allowResize)
                {
                    if (e.Y >= 0 && e.Y < 7)
                    {
                        if (e.X < 7)
                        {
                            Cursor.Current = Cursors.SizeNWSE;
                            Telerik.WinControls.NativeMethods.SendMessage(new HandleRef((object)this, form.Handle), 161, 13, IntPtr.Zero);
                        }
                        else if (e.X > this.Size.Width - 7)
                        {
                            Cursor.Current = Cursors.SizeNESW;
                            Telerik.WinControls.NativeMethods.SendMessage(new HandleRef((object)this, form.Handle), 161, 14, IntPtr.Zero);
                        }
                        else
                        {
                            Cursor.Current = Cursors.SizeNS;
                            Telerik.WinControls.NativeMethods.SendMessage(new HandleRef((object)this, form.Handle), 161, 12, IntPtr.Zero);
                        }
                    }
                    else if (e.X < 7)
                    {
                        Cursor.Current = Cursors.SizeWE;
                        Telerik.WinControls.NativeMethods.SendMessage(new HandleRef((object)this, form.Handle), 161, 10, IntPtr.Zero);
                    }
                    else if (e.X > this.Size.Width - 7)
                    {
                        Cursor.Current = Cursors.SizeWE;
                        Telerik.WinControls.NativeMethods.SendMessage(new HandleRef((object)this, form.Handle), 161, 11, IntPtr.Zero);
                    }
                }
                if (!this.canManageOwnerForm || e.X >= this.Size.Width - this.systemButtons.Size.Width)
                {
                    return;
                }
                Telerik.WinControls.NativeMethods.SendMessage(new HandleRef((object)this, form.Handle), 161, 2, IntPtr.Zero);
            }
            else
            {
                if (!this.allowResize)
                {
                    return;
                }
                if (e.Y >= 0 && e.Y < 4)
                {
                    Cursor.Current = Cursors.SizeNS;
                    if (e.X < 7)
                    {
                        Cursor.Current = Cursors.SizeNWSE;
                    }
                    else if (e.X > this.Size.Width - 7)
                    {
                        Cursor.Current = Cursors.SizeNESW;
                    }
                    else
                    {
                        Cursor.Current = Cursors.SizeNS;
                    }
                }
                else if (e.X < 7)
                {
                    Cursor.Current = Cursors.SizeWE;
                }
                else if (e.X > this.Size.Width - 7)
                {
                    Cursor.Current = Cursors.SizeWE;
                }
                else
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }