Beispiel #1
0
 protected unsafe virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
 {
     this.DemandIfUntrusted();
     if (msg != 61)
     {
         if (msg != 70)
         {
             if (msg == 130)
             {
                 this._hwnd = new HandleRef(null, IntPtr.Zero);
             }
         }
         else
         {
             PresentationSource presentationSource = PresentationSource.CriticalFromVisual(this, false);
             if (presentationSource != null)
             {
                 NativeMethods.RECT       rect = this.CalculateAssignedRC(presentationSource);
                 NativeMethods.WINDOWPOS *ptr  = (NativeMethods.WINDOWPOS *)((void *)lParam);
                 ptr->cx     = rect.right - rect.left;
                 ptr->cy     = rect.bottom - rect.top;
                 ptr->flags &= -2;
                 ptr->x      = rect.left;
                 ptr->y      = rect.top;
                 ptr->flags &= -3;
                 ptr->flags |= 256;
             }
         }
         return(IntPtr.Zero);
     }
     handled = true;
     return(this.OnWmGetObject(wParam, lParam));
 }
Beispiel #2
0
        /// <devdoc>
        ///     Handles the WM_WINDOWPOSCHANGING message
        /// </devdoc>
        /// <internalonly/>
        private unsafe void WmWindowPosChanging(ref Message m)
        {
            NativeMethods.WINDOWPOS *wp = (NativeMethods.WINDOWPOS *)m.LParam;


            bool updateSize = inAutoscale;

            if (!updateSize)
            {
                IDesignerHost host = (IDesignerHost)GetService(typeof(IDesignerHost));

                if (host != null)
                {
                    updateSize = host.Loading;
                }
            }


            // we want to update the size if we have a menu and...
            // 1) we're doing an autoscale
            // 2) we're loading a form without an inherited menu (inherited forms will already have the right size)
            //
            if (updateSize && Menu != null && (wp->flags & NativeMethods.SWP_NOSIZE) == 0 && (IsMenuInherited || inAutoscale))
            {
                heightDelta = GetMenuHeight();
            }
        }
        private unsafe void WmWindowPosChanging(ref Message m)
        {
            NativeMethods.WINDOWPOS *lParam = (NativeMethods.WINDOWPOS *)m.LParam;
            bool autoScaling = inAutoscale;

            if (!inAutoscale)
            {
                var service = GetService <IDesignerHost>();
                if (service != null)
                {
                    autoScaling = service.Loading;
                }
            }

            if (((autoScaling && (Menu != null)) && ((lParam->flags & 1) == 0)) && (IsMenuInherited || this.inAutoscale))
            {
                heightDelta = GetMenuHeight();
            }
        }
Beispiel #4
0
            private unsafe void WmWindowPosChanging(ref Message m)
            {
                NativeMethods.WINDOWPOS *windowposPtr1 = (NativeMethods.WINDOWPOS *)m.LParam;
                windowposPtr1->x = 0;
                windowposPtr1->y = 0;
                Size newSize = this.activeXBase.activeXBaseChangingSize;

                if (newSize.Width == -1)
                {
                    windowposPtr1->cx = this.activeXBase.Width;
                    windowposPtr1->cy = this.activeXBase.Height;
                }
                else
                {
                    windowposPtr1->cx = newSize.Width;
                    windowposPtr1->cy = newSize.Height;
                }
                m.Result = IntPtr.Zero;
            }
Beispiel #5
0
 protected override void WndProc(ref Message m)
 {
     //if native updown is destroyed we need release our hook
     if (m.Msg == NativeMethods.WM_DESTROY || m.Msg == NativeMethods.WM_NCDESTROY)
     {
         this.ReleaseHandle();
     }
     else if (m.Msg == NativeMethods.WM_WINDOWPOSCHANGING)
     {
         //When scroller position is changed we should remember that new position.
         unsafe
         {
             NativeMethods.WINDOWPOS *wp = (NativeMethods.WINDOWPOS *)m.LParam.ToPointer();
             this.x = wp->x;
         }
     }
     else if (m.Msg == NativeMethods.WM_MOUSEMOVE && fparent.lastHotIndex > 0 &&
              fparent.lastHotIndex != fparent.SelectedIndex)
     {
         //owerdrawing former hot tab as normal
         using (Graphics context = Graphics.FromHwnd(fparent.Handle))
         {
             VisualStyleRenderer rend = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal);
             fparent.DrawTabItem(context, fparent.lastHotIndex, fparent.GetTabRect(fparent.lastHotIndex), rend);
             if (fparent.lastHotIndex - fparent.SelectedIndex == 1)
             {
                 Rectangle selRect = fparent.GetTabRect(fparent.SelectedIndex);
                 selRect.Inflate(2, 2);
                 rend.SetParameters(rend.Class, rend.Part, (int)TabItemState.Selected);
                 fparent.DrawTabItem(context, fparent.SelectedIndex, selRect, rend);
             }
         }
     }
     else if (m.Msg == NativeMethods.WM_LBUTTONDOWN)
     {
         Rectangle invalidRect = fparent.GetTabRect(fparent.SelectedIndex);
         invalidRect.X = 0; invalidRect.Width = 2;
         invalidRect.Inflate(0, 2);
         fparent.Invalidate(invalidRect);
     }
     base.WndProc(ref m);
 }
Beispiel #6
0
        /// <summary>
        ///     A protected override for accessing the window proc of the
        ///     hosted child window.
        /// </summary>
        ///<remarks> Not available in Internet zone</remarks>
        protected virtual IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            DemandIfUntrusted();

            switch ((WindowMessage)msg)
            {
            case WindowMessage.WM_NCDESTROY:
                _hwnd = new HandleRef(null, IntPtr.Zero);
                break;

            // When layout happens, we first calculate the right size/location then call SetWindowPos.
            // We only allow the changes that are coming from Avalon layout. The hwnd is not allowed to change by itself.
            // So the size of the hwnd should always be RenderSize and the position be where layout puts it.
            case WindowMessage.WM_WINDOWPOSCHANGING:
                PresentationSource source = PresentationSource.CriticalFromVisual(this, false /* enable2DTo3DTransition */);

                if (source != null)
                {
                    // Get the rect assigned by layout to us.
                    NativeMethods.RECT assignedRC = CalculateAssignedRC(source);

                    // The lParam is a pointer to a WINDOWPOS structure
                    // that contains information about the size and
                    // position that the window is changing to.  Note that
                    // modifying this structure during WM_WINDOWPOSCHANGING
                    // will change what happens to the window.
                    unsafe
                    {
                        NativeMethods.WINDOWPOS *windowPos = (NativeMethods.WINDOWPOS *)lParam;

                        // Always force the size of the window to be the
                        // size of our assigned rectangle.  Note that we
                        // have to always clear the SWP_NOSIZE flag.
                        windowPos->cx     = assignedRC.right - assignedRC.left;
                        windowPos->cy     = assignedRC.bottom - assignedRC.top;
                        windowPos->flags &= ~NativeMethods.SWP_NOSIZE;

                        // Always force the position of the window to be
                        // the upper-left corner of our assigned rectangle.
                        // Note that we have to always clear the
                        // SWP_NOMOVE flag.
                        windowPos->x      = assignedRC.left;
                        windowPos->y      = assignedRC.top;
                        windowPos->flags &= ~NativeMethods.SWP_NOMOVE;

                        // Windows has an optimization to copy pixels
                        // around to reduce the amount of repainting
                        // needed when moving or resizing a window.
                        // Unfortunately, this is not compatible with WPF
                        // in many cases due to our use of DirectX for
                        // rendering from our rendering thread.
                        // To be safe, we disable this optimization and
                        // pay the cost of repainting.
                        windowPos->flags |= NativeMethods.SWP_NOCOPYBITS;
                    }
                }

                break;


            case WindowMessage.WM_GETOBJECT:
                handled = true;
                return(OnWmGetObject(wParam, lParam));
            }

            return(IntPtr.Zero);
        }