Example #1
0
        protected virtual void OnWindowPosChanging(ref Message m, NuGenWndProcDelegate baseWndProc)
        {
            Debug.Assert(m != null, "m != null");
            Debug.Assert(baseWndProc != null, "baseWndProc != null");
            Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

            WINDOWPOS wndPos = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS));
            Rectangle bounds = Window.GetBounds(m.HWnd);

            if (
                Window.GetState(m.HWnd) == FormWindowState.Minimized ||
                _shouldReduceBounds
                )
            {
                int width  = wndPos.width;
                int height = wndPos.height;

                if (width != bounds.Width || height != bounds.Height)
                {
                    this.AdjustBounds(m.HWnd, ref width, ref height);
                }

                wndPos.width  = width;
                wndPos.height = height;

                _shouldReduceBounds = true;
            }

            Marshal.StructureToPtr(wndPos, m.LParam, false);
        }
Example #2
0
        protected virtual void OnWmNcPaint(ref Message m, NuGenWndProcDelegate baseWndProc)
        {
            Debug.Assert(m != null, "m != null");
            Debug.Assert(baseWndProc != null, "baseWndProc != null");

            m.Result = Common.FALSE;
        }
Example #3
0
 protected virtual void OnNonDocumented(ref Message m, NuGenWndProcDelegate baseWndProc)
 {
     /*
      * Should ignore this non-documented message. Otherwise, caption buttons will appear
      * under certain circumstances.
      */
     return;
 }
Example #4
0
        protected virtual void OnWmSetText(ref Message m, NuGenWndProcDelegate baseWndProc)
        {
            Debug.Assert(m != null, "m != null");
            Debug.Assert(baseWndProc != null, "baseWndProc != null");
            Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

            baseWndProc(ref m);
            User32.InvalidateRect(m.HWnd, IntPtr.Zero, true);
        }
Example #5
0
        protected virtual void OnWmWindowPosChanged(ref Message m, NuGenWndProcDelegate baseWndProc)
        {
            Debug.Assert(m != null, "m != null");
            Debug.Assert(baseWndProc != null, "baseWndProc != null");
            Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

            baseWndProc(ref m);

            FormWindowState state = Window.GetState(m.HWnd);

            if (
                Window.GetState(m.HWnd) == FormWindowState.Normal
                )
            {
                _shouldReduceBounds = false;
                baseWndProc(ref m);
                return;
            }

            _shouldReduceBounds = true;
            baseWndProc(ref m);
            _shouldReduceBounds = true;
        }
Example #6
0
        protected virtual void OnWmNcCalcSize(ref Message m, NuGenWndProcDelegate baseWndProc)
        {
            Debug.Assert(m != null, "m != null");
            Debug.Assert(baseWndProc != null, "baseWndProc != null");
            Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

            baseWndProc(ref m);

            if (m.WParam == Common.FALSE)
            {
                RECT rect = (RECT)Marshal.PtrToStructure(m.LParam, typeof(RECT));

                Marshal.StructureToPtr(
                    (RECT)this.GetClientRectangle(m.HWnd, (Rectangle)rect),
                    m.LParam,
                    false
                    );

                m.Result = Common.FALSE;
            }
            else
            {
                NCCALCSIZE_PARAMS calcSizeParams = (NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS));
                WINDOWPOS         wndPos         = (WINDOWPOS)Marshal.PtrToStructure(calcSizeParams.lppos, typeof(WINDOWPOS));
                RECT bufferRect = (RECT)this.GetClientRectangle(
                    m.HWnd,
                    new Rectangle(wndPos.x, wndPos.y, wndPos.width, wndPos.height)
                    );

                calcSizeParams.rectProposed   = bufferRect;
                calcSizeParams.rectBeforeMove = bufferRect;

                Marshal.StructureToPtr(calcSizeParams, m.LParam, false);

                m.Result = new IntPtr(WinUser.WVR_VALIDRECTS);
            }
        }
 protected virtual void OnWmLButtonClick(ref Message m, NuGenWndProcDelegate baseWndProc)
 {
 }
			protected void WmHandler2(ref Message m, NuGenWndProcDelegate baseWndProc)
			{
				_wmHandler2InvokeCount.Inc();
			}
		protected virtual void OnWindowPosChanging(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			Debug.Assert(m != null, "m != null");
			Debug.Assert(baseWndProc != null, "baseWndProc != null");
			Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

			WINDOWPOS wndPos = (WINDOWPOS)m.GetLParam(typeof(WINDOWPOS));
			Rectangle bounds = Window.GetBounds(m.HWnd);

			if (
				Window.GetState(m.HWnd) == FormWindowState.Minimized
				|| _shouldReduceBounds
				)
			{
				int width = wndPos.width;
				int height = wndPos.height;

				if (width != bounds.Width || height != bounds.Height)
				{
					this.AdjustBounds(m.HWnd, ref width, ref height);
				}

				wndPos.width = width;
				wndPos.height = height;

				_shouldReduceBounds = true;
			}

			Marshal.StructureToPtr(wndPos, m.LParam, false);
		}
		protected virtual void OnWmSetText(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			Debug.Assert(m != null, "m != null");
			Debug.Assert(baseWndProc != null, "baseWndProc != null");
			Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

			baseWndProc(ref m);
			User32.InvalidateRect(m.HWnd, IntPtr.Zero, true);
		}
		protected virtual void OnWmNcHitTest(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			Debug.Assert(m != null, "m != null");
			Debug.Assert(baseWndProc != null, "baseWndProc != null");
			Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

			Point testPoint = NuGenControlPaint.BuildMousePos(m.LParam);
			User32.ScreenToClient(m.HWnd, ref testPoint);

			int largeOffset = 4;
			int smallOffset = 1;

			Rectangle bounds = Window.GetBounds(m.HWnd);
			Rectangle testRect = Rectangle.Empty;

			if (this.IsSizable(m.HWnd))
			{
				testRect = new Rectangle(
					0,
					0,
					bounds.Width,
					largeOffset
				);

				if (testRect.Contains(testPoint))
				{
					m.Result = new IntPtr(WinUser.HTTOP);
					return;
				}

				testRect = new Rectangle(
					0,
					bounds.Height - largeOffset,
					bounds.Width,
					largeOffset
				);

				if (testRect.Contains(testPoint))
				{
					m.Result = new IntPtr(WinUser.HTBOTTOM);
					return;
				}

				if (Window.IsRightToLeft(m.HWnd))
				{
					testRect = new Rectangle(
						bounds.Width - this.FormProperties.TopRightCornerSize,
						0,
						this.FormProperties.TopRightCornerSize + smallOffset,
						this.FormProperties.TopRightCornerSize + smallOffset
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTTOPLEFT);
						return;
					}

					testRect = new Rectangle(
						0,
						0,
						this.FormProperties.TopLeftCornerSize + smallOffset,
						this.FormProperties.TopLeftCornerSize + smallOffset
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTTOPRIGHT);
						return;
					}

					testRect = new Rectangle(
						bounds.Width - this.FormProperties.BottomRightCornerSize,
						bounds.Height - this.FormProperties.BottomRightCornerSize,
						this.FormProperties.BottomRightCornerSize + smallOffset,
						this.FormProperties.BottomRightCornerSize + smallOffset
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTBOTTOMLEFT);
						return;
					}

					testRect = new Rectangle(
						0,
						bounds.Height - this.FormProperties.BottomLeftCornerSize,
						this.FormProperties.BottomLeftCornerSize + smallOffset,
						this.FormProperties.BottomLeftCornerSize + smallOffset
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTBOTTOMRIGHT);
						return;
					}

					testRect = new Rectangle(
						bounds.Width - largeOffset,
						0,
						largeOffset,
						bounds.Height
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTLEFT);
						return;
					}

					testRect = new Rectangle(0, 0, largeOffset, bounds.Height);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTRIGHT);
						return;
					}
				}
				else
				{
					testRect = new Rectangle(
						0,
						0,
						this.FormProperties.TopLeftCornerSize + smallOffset,
						this.FormProperties.TopLeftCornerSize + smallOffset
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTTOPLEFT);
						return;
					}

					testRect = new Rectangle(
						bounds.Width - this.FormProperties.TopRightCornerSize,
						0,
						this.FormProperties.TopRightCornerSize + smallOffset,
						this.FormProperties.TopRightCornerSize + smallOffset
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTTOPRIGHT);
						return;
					}

					testRect = new Rectangle(
						0,
						bounds.Height - this.FormProperties.BottomLeftCornerSize,
						this.FormProperties.BottomLeftCornerSize + smallOffset,
						this.FormProperties.BottomLeftCornerSize + smallOffset
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTBOTTOMLEFT);
						return;
					}

					testRect = new Rectangle(
						bounds.Width - this.FormProperties.BottomLeftCornerSize,
						bounds.Height - this.FormProperties.BottomRightCornerSize,
						this.FormProperties.BottomRightCornerSize + smallOffset,
						this.FormProperties.BottomRightCornerSize + smallOffset
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTBOTTOMRIGHT);
						return;
					}

					testRect = new Rectangle(
						0,
						0,
						largeOffset,
						bounds.Height
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTLEFT);
						return;
					}

					testRect = new Rectangle(
						bounds.Width - largeOffset,
						0,
						largeOffset,
						bounds.Height
					);

					if (testRect.Contains(testPoint))
					{
						m.Result = new IntPtr(WinUser.HTRIGHT);
						return;
					}
				}
			}

			// HACK: For testing purposes only.
			m.Result = (IntPtr)WinUser.HTCAPTION;
		}
		protected virtual void OnWmNcActivate(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			m.Result = Common.TRUE;
		}
Example #13
0
        protected virtual void OnWmNcHitTest(ref Message m, NuGenWndProcDelegate baseWndProc)
        {
            Debug.Assert(m != null, "m != null");
            Debug.Assert(baseWndProc != null, "baseWndProc != null");
            Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

            Point testPoint = NuGenControlPaint.BuildMousePos(m.LParam);

            User32.ScreenToClient(m.HWnd, ref testPoint);

            int largeOffset = 4;
            int smallOffset = 1;

            Rectangle bounds   = Window.GetBounds(m.HWnd);
            Rectangle testRect = Rectangle.Empty;

            if (this.IsSizable(m.HWnd))
            {
                testRect = new Rectangle(
                    0,
                    0,
                    bounds.Width,
                    largeOffset
                    );

                if (testRect.Contains(testPoint))
                {
                    m.Result = new IntPtr(WinUser.HTTOP);
                    return;
                }

                testRect = new Rectangle(
                    0,
                    bounds.Height - largeOffset,
                    bounds.Width,
                    largeOffset
                    );

                if (testRect.Contains(testPoint))
                {
                    m.Result = new IntPtr(WinUser.HTBOTTOM);
                    return;
                }

                if (Window.IsRightToLeft(m.HWnd))
                {
                    testRect = new Rectangle(
                        bounds.Width - this.FormProperties.TopRightCornerSize,
                        0,
                        this.FormProperties.TopRightCornerSize + smallOffset,
                        this.FormProperties.TopRightCornerSize + smallOffset
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTTOPLEFT);
                        return;
                    }

                    testRect = new Rectangle(
                        0,
                        0,
                        this.FormProperties.TopLeftCornerSize + smallOffset,
                        this.FormProperties.TopLeftCornerSize + smallOffset
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTTOPRIGHT);
                        return;
                    }

                    testRect = new Rectangle(
                        bounds.Width - this.FormProperties.BottomRightCornerSize,
                        bounds.Height - this.FormProperties.BottomRightCornerSize,
                        this.FormProperties.BottomRightCornerSize + smallOffset,
                        this.FormProperties.BottomRightCornerSize + smallOffset
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTBOTTOMLEFT);
                        return;
                    }

                    testRect = new Rectangle(
                        0,
                        bounds.Height - this.FormProperties.BottomLeftCornerSize,
                        this.FormProperties.BottomLeftCornerSize + smallOffset,
                        this.FormProperties.BottomLeftCornerSize + smallOffset
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTBOTTOMRIGHT);
                        return;
                    }

                    testRect = new Rectangle(
                        bounds.Width - largeOffset,
                        0,
                        largeOffset,
                        bounds.Height
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTLEFT);
                        return;
                    }

                    testRect = new Rectangle(0, 0, largeOffset, bounds.Height);

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTRIGHT);
                        return;
                    }
                }
                else
                {
                    testRect = new Rectangle(
                        0,
                        0,
                        this.FormProperties.TopLeftCornerSize + smallOffset,
                        this.FormProperties.TopLeftCornerSize + smallOffset
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTTOPLEFT);
                        return;
                    }

                    testRect = new Rectangle(
                        bounds.Width - this.FormProperties.TopRightCornerSize,
                        0,
                        this.FormProperties.TopRightCornerSize + smallOffset,
                        this.FormProperties.TopRightCornerSize + smallOffset
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTTOPRIGHT);
                        return;
                    }

                    testRect = new Rectangle(
                        0,
                        bounds.Height - this.FormProperties.BottomLeftCornerSize,
                        this.FormProperties.BottomLeftCornerSize + smallOffset,
                        this.FormProperties.BottomLeftCornerSize + smallOffset
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTBOTTOMLEFT);
                        return;
                    }

                    testRect = new Rectangle(
                        bounds.Width - this.FormProperties.BottomLeftCornerSize,
                        bounds.Height - this.FormProperties.BottomRightCornerSize,
                        this.FormProperties.BottomRightCornerSize + smallOffset,
                        this.FormProperties.BottomRightCornerSize + smallOffset
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTBOTTOMRIGHT);
                        return;
                    }

                    testRect = new Rectangle(
                        0,
                        0,
                        largeOffset,
                        bounds.Height
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTLEFT);
                        return;
                    }

                    testRect = new Rectangle(
                        bounds.Width - largeOffset,
                        0,
                        largeOffset,
                        bounds.Height
                        );

                    if (testRect.Contains(testPoint))
                    {
                        m.Result = new IntPtr(WinUser.HTRIGHT);
                        return;
                    }
                }
            }

            // HACK: For testing purposes only.
            m.Result = (IntPtr)WinUser.HTCAPTION;
        }
Example #14
0
 protected virtual void OnWmNcActivate(ref Message m, NuGenWndProcDelegate baseWndProc)
 {
     m.Result = Common.TRUE;
 }
Example #15
0
 protected virtual void OnWmEraseBkgnd(ref Message m, NuGenWndProcDelegate baseWndProc)
 {
     m.Result = Common.TRUE;             // Non-zero to erase background.
 }
		protected virtual void OnNonDocumented(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			/*
			 * Should ignore this non-documented message. Otherwise, caption buttons will appear
			 * under certain circumstances.
			 */
			return;
		}
		protected virtual void OnWmEraseBkgnd(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			m.Result = Common.TRUE; // Non-zero to erase background.
		}
Example #18
0
 public FormSystemLayer(Form host, NuGenWndProcDelegate parentWndProc)
 {
     _host          = host;
     _parentWndProc = parentWndProc;
 }
		protected virtual void OnWmNcCalcSize(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			Debug.Assert(m != null, "m != null");
			Debug.Assert(baseWndProc != null, "baseWndProc != null");
			Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

			baseWndProc(ref m);

			if (m.WParam == Common.FALSE)
			{
				RECT rect = (RECT)Marshal.PtrToStructure(m.LParam, typeof(RECT));

				Marshal.StructureToPtr(
					(RECT)this.GetClientRectangle(m.HWnd, (Rectangle)rect),
					m.LParam,
					false
				);

				m.Result = Common.FALSE;
			}
			else
			{
				NCCALCSIZE_PARAMS calcSizeParams = (NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS));
				WINDOWPOS wndPos = (WINDOWPOS)Marshal.PtrToStructure(calcSizeParams.lppos, typeof(WINDOWPOS));
				RECT bufferRect = (RECT)this.GetClientRectangle(
					m.HWnd,
					new Rectangle(wndPos.x, wndPos.y, wndPos.width, wndPos.height)
				);

				calcSizeParams.rectProposed = bufferRect;
				calcSizeParams.rectBeforeMove = bufferRect;

				Marshal.StructureToPtr(calcSizeParams, m.LParam, false);

				m.Result = new IntPtr(WinUser.WVR_VALIDRECTS);
			}
		}
		public FormSystemLayer(Form host, NuGenWndProcDelegate parentWndProc)
		{
			_host = host;
			_parentWndProc = parentWndProc;
		}
		protected virtual void OnWmNcPaint(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			Debug.Assert(m != null, "m != null");
			Debug.Assert(baseWndProc != null, "baseWndProc != null");

			m.Result = Common.FALSE;
		}
 private void StubWmHandler2(ref Message m, NuGenWndProcDelegate baseWndProc)
 {
 }
		protected virtual void OnWmWindowPosChanged(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
			Debug.Assert(m != null, "m != null");
			Debug.Assert(baseWndProc != null, "baseWndProc != null");
			Debug.Assert(User32.IsWindow(m.HWnd), "User32.IsWindow(m.HWnd)");

			baseWndProc(ref m);

			FormWindowState state = Window.GetState(m.HWnd);

			if (
				Window.GetState(m.HWnd) == FormWindowState.Normal
				)
			{
				_shouldReduceBounds = false;
				baseWndProc(ref m);
				return;
			}

			_shouldReduceBounds = true;
			baseWndProc(ref m);
			_shouldReduceBounds = true;
		}
 protected void WmHandler2(ref Message m, NuGenWndProcDelegate baseWndProc)
 {
     _wmHandler2InvokeCount.Inc();
 }
		private void StubWmHandler2(ref Message m, NuGenWndProcDelegate baseWndProc)
		{
		}
			protected virtual void OnWmPaint(ref Message m, NuGenWndProcDelegate baseWndProc)
			{
			}
 protected virtual void OnWmPaint(ref Message m, NuGenWndProcDelegate baseWndProc)
 {
 }
			protected virtual void OnWmLButtonClick(ref Message m, NuGenWndProcDelegate baseWndProc)
			{
			}
			private void OnLButtonDown(ref Message m, NuGenWndProcDelegate baseWndProc)
			{
				_onLButtonDownInvokeCount.Inc();
			}
 private void OnLButtonDown(ref Message m, NuGenWndProcDelegate baseWndProc)
 {
     _onLButtonDownInvokeCount.Inc();
 }