当前位置: 首页>>代码示例>>C#>>正文


C# IntPtr.ToPoint方法代码示例

本文整理汇总了C#中System.IntPtr.ToPoint方法的典型用法代码示例。如果您正苦于以下问题:C# IntPtr.ToPoint方法的具体用法?C# IntPtr.ToPoint怎么用?C# IntPtr.ToPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IntPtr的用法示例。


在下文中一共展示了IntPtr.ToPoint方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WndProc

		private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
		{
			if (msg == (int)WM.NCHITTEST && this.canResize)
			{
				var ptScreen = lParam.ToPoint();
				var ptClient = this.PointFromScreen(ptScreen);
				var rectTarget = new Rect(0, 0, this.ActualWidth, this.ActualHeight);

				if (rectTarget.Contains(ptClient))
				{
					handled = true;
					return (IntPtr)HitTestValues.HTBOTTOMRIGHT;
				}
			}

			return IntPtr.Zero;
		}
开发者ID:Grabacr07,项目名称:Mukyutter.Old,代码行数:17,代码来源:ResizeGrip.cs

示例2: WndProc

		private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
		{
			if (msg == (int)WM.MOUSEACTIVATE)
			{
				handled = true;
				return new IntPtr(3);
			}

			if (msg == (int)WM.LBUTTONDOWN)
			{
				var ptScreen = lParam.ToPoint();

				User32.PostMessage(
					this.ownerHandle, 
					(uint)WM.NCLBUTTONDOWN,
					(IntPtr)this.processor.GetHitTestValue(ptScreen, this.ActualWidth, this.ActualHeight), 
					IntPtr.Zero);
			}
			if (msg == (int)WM.NCHITTEST)
			{
				var ptScreen = lParam.ToPoint();
				var ptClient = this.PointFromScreen(ptScreen);

				this.Cursor = this.processor.GetCursor(ptClient, this.ActualWidth, this.ActualHeight);
			}

			return IntPtr.Zero;
		}
开发者ID:Grabacr07,项目名称:Mukyutter.Old,代码行数:28,代码来源:GlowWindow.cs

示例3: WndProc

		private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
		{
			if (msg == (int)WM.MOUSEACTIVATE)
			{
				handled = true;
				return new IntPtr(3);
			}

			if (msg == (int)WM.LBUTTONDOWN)
			{
				if (!this.owner.IsActive)
				{
					this.owner.Activate();
				}

				var ptScreen = lParam.ToPoint();

				NativeMethods.PostMessage(
					this.ownerHandle,
					(uint)WM.NCLBUTTONDOWN,
					(IntPtr)this.processor.GetHitTestValue(ptScreen, this.ActualWidth, this.ActualHeight),
					IntPtr.Zero);
			}
			if (msg == (int)WM.NCHITTEST)
			{
				var ptScreen = lParam.ToPoint();
				var ptClient = this.PointFromScreen(ptScreen);

				this.Cursor = this.processor.GetCursor(ptClient, this.ActualWidth, this.ActualHeight);
			}

			if (msg == (int)WM.LBUTTONDBLCLK)
			{
				if (this.processor.GetType() == typeof(GlowWindowProcessorTop))
				{
					NativeMethods.SendMessage(this.ownerHandle, WM.NCLBUTTONDBLCLK, (IntPtr)HitTestValues.HTTOP, IntPtr.Zero);
				}
				else if (this.processor.GetType() == typeof(GlowWindowProcessorBottom))
				{
					NativeMethods.SendMessage(this.ownerHandle, WM.NCLBUTTONDBLCLK, (IntPtr)HitTestValues.HTBOTTOM, IntPtr.Zero);
				}
			}

			return IntPtr.Zero;
		}
开发者ID:WizFox,项目名称:MetroRadiance,代码行数:45,代码来源:GlowWindow.cs

示例4: WndProc

        IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            IntPtr retVal = IntPtr.Zero;
            if (!handled)
            {
                var wmsg = (WindowMessage)msg;
                //Debug.WriteLine(wmsg);
                switch (wmsg)
                {
                    //case WindowMessage.WM_SETTEXT:
                    //case WindowMessage.WM_SETICON:
                    //    var changed = User32Ex.ModifyStyle(hwnd, WindowStyles.WS_VISIBLE, WindowStyles.WS_OVERLAPPED);
                    //    retVal = User32.DefWindowProc(hwnd, (uint)msg, wParam, lParam);
                    //    if (changed) { User32Ex.ModifyStyle(hwnd, WindowStyles.WS_OVERLAPPED, WindowStyles.WS_VISIBLE); }
                    //    handled = true;
                    //    break;
                    case WindowMessage.WM_NCUAHDRAWCAPTION:
                    case WindowMessage.WM_NCUAHDRAWFRAME:
                        // undocumented stuff for lame non-dwm themes that will sometimes draw old control buttons
                        handled = true;
                        break;
                    case WindowMessage.WM_NCHITTEST:
                        retVal = new IntPtr((int)HandleNcHitTest(lParam.ToPoint()));
                        handled = true;
                        break;
                    case WindowMessage.WM_NCRBUTTONDOWN:
                    case WindowMessage.WM_NCMBUTTONDOWN:
                    case WindowMessage.WM_NCRBUTTONDBLCLK:
                    case WindowMessage.WM_NCMBUTTONDBLCLK:
                    case WindowMessage.WM_RBUTTONDBLCLK:
                    case WindowMessage.WM_MBUTTONDBLCLK:
                    case WindowMessage.WM_LBUTTONDBLCLK:
                        handled = true;
                        if (_contentWindow != null)
                            _contentWindow.Activate();
                        break;
                    case WindowMessage.WM_NCLBUTTONDOWN:
                    case WindowMessage.WM_NCLBUTTONDBLCLK:
                        Debug.WriteLine("Got border LButton down");
                        handled = true;
                        // pass resizer msg to the content window instead
                        if (_contentWindow != null)
                        {
                            _contentWindow.Activate();
                            var cwHwnd = new WindowInteropHelper(_contentWindow).Handle;
                            User32.SendMessage(cwHwnd, (uint)msg, wParam, IntPtr.Zero);
                        }
                        break;
                    case WindowMessage.WM_MOUSEACTIVATE:
                        var lowword = 0xffff & lParam.ToInt32();
                        var hchit = (NcHitTest)lowword;

                        // in case of non-resizable window eat this msg
                        if (hchit == NcHitTest.HTCLIENT)
                        {
                            retVal = new IntPtr((int)MouseActivate.MA_NOACTIVATEANDEAT);
                        }
                        else
                        {
                            retVal = new IntPtr((int)MouseActivate.MA_NOACTIVATE);
                        }
                        handled = true;
                        break;
                    case WindowMessage.WM_ERASEBKGND:
                        // prevent more flickers
                        handled = true;
                        break;
                    case WindowMessage.WM_GETMINMAXINFO:
                        HandleMinMaxInfo(lParam);
                        break;
                }
            }
            return retVal;
        }
开发者ID:soukoku,项目名称:ModernWPF,代码行数:74,代码来源:LegacyBorderWindow.cs

示例5: WndProc

        private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            if (msg == (int)WM.NCHITTEST)
            {
                if (this.ResizeMode == ResizeMode.CanResizeWithGrip
                    && this.WindowState == WindowState.Normal
                    && this.resizeGrip != null)
                {
                    var ptScreen = lParam.ToPoint();
                    var ptClient = this.resizeGrip.PointFromScreen(ptScreen);

                    var rectTarget = new Rect(0, 0, this.resizeGrip.ActualWidth, this.resizeGrip.ActualHeight);
                    if (rectTarget.Contains(ptClient))
                    {
                        handled = true;
                        return (IntPtr)HitTestValues.HTBOTTOMRIGHT;
                    }
                }
            }
            else if (msg == (int)WM.DPICHANGED)
            {
                var dpiX = wParam.ToLoWord();
                var dpiY = wParam.ToHiWord();
                this.ChangeDpi(new Dpi(dpiX, dpiY));
                handled = true;
            }

            return IntPtr.Zero;
        }
开发者ID:Grabacr07,项目名称:MetroRadiance,代码行数:29,代码来源:MetroWindow.cs

示例6: WndProc

        IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            IntPtr retVal = IntPtr.Zero;
            if (!handled)
            {
                var wmsg = (WindowMessage)msg;
                //Debug.WriteLine(wmsg);
                switch (wmsg)
                {
                    case WindowMessage.WM_NCCALCSIZE:
                        handled = true;
                        break;
                    case WindowMessage.WM_NCHITTEST:
                        NcHitTest res = NcHitTest.HTBORDER;
                        if (_manager.ContentWindow.ResizeMode == ResizeMode.CanResizeWithGrip ||
                            _manager.ContentWindow.ResizeMode == ResizeMode.CanResize)
                        {
                            var pt = PointFromScreen(lParam.ToPoint());
                            int diagSize = (int)(2 * PadSize);
                            switch (Side)
                            {
                                case BorderSide.Left:
                                    if (pt.Y <= diagSize) { res = NcHitTest.HTTOPLEFT; }
                                    else if (pt.Y >= Height - diagSize) { res = NcHitTest.HTBOTTOMLEFT; }
                                    else { res = NcHitTest.HTLEFT; }
                                    break;
                                case BorderSide.Top:
                                    if (pt.X <= diagSize) { res = NcHitTest.HTTOPLEFT; }
                                    else if (pt.X >= Width - diagSize) { res = NcHitTest.HTTOPRIGHT; }
                                    else { res = NcHitTest.HTTOP; }
                                    break;
                                case BorderSide.Right:
                                    if (pt.Y <= diagSize) { res = NcHitTest.HTTOPRIGHT; }
                                    else if (pt.Y >= Height - diagSize) { res = NcHitTest.HTBOTTOMRIGHT; }
                                    else { res = NcHitTest.HTRIGHT; }
                                    break;
                                case BorderSide.Bottom:
                                    if (pt.X <= diagSize) { res = NcHitTest.HTBOTTOMLEFT; }
                                    else if (pt.X >= Width - diagSize) { res = NcHitTest.HTBOTTOMRIGHT; }
                                    else { res = NcHitTest.HTBOTTOM; }
                                    break;
                            }
                        }
                        retVal = new IntPtr((int)res);
                        handled = true;
                        break;
                    case WindowMessage.WM_NCRBUTTONDOWN:
                    case WindowMessage.WM_NCMBUTTONDOWN:
                    case WindowMessage.WM_NCRBUTTONDBLCLK:
                    case WindowMessage.WM_NCMBUTTONDBLCLK:
                    case WindowMessage.WM_RBUTTONDBLCLK:
                    case WindowMessage.WM_MBUTTONDBLCLK:
                    case WindowMessage.WM_LBUTTONDBLCLK:
                        handled = true;
                        User32.SetForegroundWindow(_manager.hWndContent);
                        break;
                    case WindowMessage.WM_NCLBUTTONDOWN:
                    case WindowMessage.WM_NCLBUTTONDBLCLK:
                        handled = true;
                        // pass resizer msg to the content window instead
                        User32.SetForegroundWindow(_manager.hWndContent);
                        User32.SendMessage(_manager.hWndContent, (uint)msg, wParam, lParam);
                        break;
                    case WindowMessage.WM_MOUSEACTIVATE:
                        var lowword = 0xffff & lParam.ToInt32();
                        var hchit = (NcHitTest)lowword;

                        // in case of non-resizable window eat this msg
                        if (hchit == NcHitTest.HTCLIENT)
                        {
                            retVal = new IntPtr((int)MouseActivate.MA_NOACTIVATEANDEAT);
                        }
                        else
                        {
                            retVal = new IntPtr((int)MouseActivate.MA_NOACTIVATE);
                        }
                        handled = true;
                        break;
                    case WindowMessage.WM_GETMINMAXINFO:
                        // overridden so max size = normal max + resize border (for when content window is max size without maximizing)
                        var thick = 2 * (int)PadSize;

                        MINMAXINFO para = (MINMAXINFO)Marshal.PtrToStructure(lParam, typeof(MINMAXINFO));
                        var orig = para.ptMaxTrackSize;
                        orig.x += thick;
                        orig.y += thick;
                        para.ptMaxTrackSize = orig;
                        Marshal.StructureToPtr(para, lParam, true);
                        break;
                }
            }
            return retVal;
        }
开发者ID:soukoku,项目名称:ModernWPF,代码行数:93,代码来源:BorderWindow.cs

示例7: HandleNcHitTest

        private NcHitTest HandleNcHitTest(IntPtr hWnd, IntPtr lParam)
        {
            Point screenPoint = lParam.ToPoint();
            Point windowPoint = ContentWindow.PointFromScreen(screenPoint);
            var capH = (double)WindowCaptionHeightConverter.Instance.Convert(Chrome.GetCaptionHeight(ContentWindow), typeof(Double), null, CultureInfo.CurrentCulture);
            //double capH = (windowCapH > -1 ? windowCapH : ContentWindow.ActualHeight);

            NcHitTest location = NcHitTest.HTCLIENT;
            var hitTest = ContentWindow.InputHitTest(windowPoint);

            if (hitTest != null && (windowPoint.Y <= capH || Chrome.GetIsCaption(hitTest)) &&
                !Chrome.GetIsHitTestVisible(hitTest))
            {
                location = NcHitTest.HTCAPTION;
                if (windowPoint.Y <= 40)
                {
                    // check for sysmenu style
                    if (((WindowStyles)User32.GetWindowLong(hWndContent, CommonWin32.WindowClasses.WindowLong.GWL_STYLE)).HasFlag(WindowStyles.WS_SYSMENU))
                    {
                        if (ContentWindow.FlowDirection == System.Windows.FlowDirection.LeftToRight)
                        {
                            if (windowPoint.X <= 40)
                            {
                                location = NcHitTest.HTSYSMENU;
                            }
                        }
                        else if (windowPoint.X >= (ContentWindow.ActualWidth - 40))
                        {
                            location = NcHitTest.HTSYSMENU;
                        }
                    }
                }
            }

            if (_resizeGrip != null && _resizeGrip.Visibility == System.Windows.Visibility.Visible &&
                VisualTreeHelper.HitTest(_resizeGrip, _resizeGrip.PointFromScreen(screenPoint)) != null)
            {
                location = _resizeGrip.FlowDirection == System.Windows.FlowDirection.LeftToRight ?
                    NcHitTest.HTBOTTOMRIGHT : NcHitTest.HTBOTTOMLEFT;
            }

            //Debug.WriteLine(location);
            return location;
        }
开发者ID:soukoku,项目名称:ModernWPF,代码行数:44,代码来源:BorderManager.cs

示例8: HandleNcHitTest

        private NcHitTest HandleNcHitTest(IntPtr lParam)
        {
            Point windowPoint = ContentWindow.PointFromScreen(lParam.ToPoint());
            var capH = SystemParameters.CaptionHeight;// (double)WindowCaptionHeightConverter.Instance.Convert(GetCaptionHeight(_contentWindow), typeof(Double), null, CultureInfo.CurrentCulture);
            //double capH = (windowCapH > -1 ? windowCapH : _contentWindow.ActualHeight);

            NcHitTest location = NcHitTest.HTCLIENT;
            var hitTest = ContentWindow.InputHitTest(windowPoint);

            if (hitTest != null && (windowPoint.Y <= capH))// || GetIsCaption(hitTest)) && !GetIsHitTestVisible(hitTest))
            {
                location = NcHitTest.HTCAPTION;
                if (windowPoint.Y <= 40)
                {
                    if (ContentWindow.FlowDirection == System.Windows.FlowDirection.LeftToRight)
                    {
                        if (windowPoint.X <= 40)
                        {
                            location = NcHitTest.HTSYSMENU;
                        }
                    }
                    else if (windowPoint.X >= (ContentWindow.ActualWidth - 40))
                    {
                        location = NcHitTest.HTSYSMENU;
                    }
                }
            }

            //if (_resizeGrip != null && _resizeGrip.Visibility == System.Windows.Visibility.Visible &&
            //    VisualTreeHelper.HitTest(_resizeGrip, _resizeGrip.PointFromScreen(screenPoint)) != null)
            //{
            //    location = _resizeGrip.FlowDirection == System.Windows.FlowDirection.LeftToRight ?
            //        NcHitTest.HTBOTTOMRIGHT : NcHitTest.HTBOTTOMLEFT;
            //}

            //Debug.WriteLine(location);
            return location;
        }
开发者ID:soukoku,项目名称:CustomWindowBorder,代码行数:38,代码来源:BorderManager.cs

示例9: WndProc

        /// <summary>
        /// Handles Win32 window messages for this window.
        /// </summary>
        /// <param name="hwnd">The window handle.</param>
        /// <param name="msg">The message ID.</param>
        /// <param name="wParam">The message's wParam value.</param>
        /// <param name="lParam">The message's lParam value.</param>
        /// <param name="handled">A value that indicates whether the message was handled. Set the value to
        /// true if the message was handled; otherwise, false.</param>
        /// <returns></returns>
        IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            IntPtr retVal = IntPtr.Zero;
            if (!handled)
            {
                var wmsg = (WindowMessage)msg;
                //Debug.WriteLine(wmsg);
                switch (wmsg)
                {
                    case WindowMessage.WM_MOUSEHWHEEL:
                        // do our own horizontal wheel event
                        var element = Mouse.DirectlyOver;
                        if (element != null)
                        {
                            var delta = wParam.ToInt32() >> 16;
                            var arg = new MouseWheelEventArgs(InputManager.Current.PrimaryMouseDevice, Environment.TickCount, delta)
                            {
                                RoutedEvent = MouseEvents.PreviewMouseHWheelEvent
                            };
                            element.RaiseEvent(arg);
                            if (!arg.Handled)
                            {
                                arg.RoutedEvent = MouseEvents.MouseHWheelEvent;
                                arg.Handled = false;
                                element.RaiseEvent(arg);

                                handled = arg.Handled;
                            }
                        }
                        break;
                    //case WindowMessage.WM_SETTEXT:
                    //case WindowMessage.WM_SETICON:
                    //    var changed = User32Ex.ModifyStyle(hwnd, WindowStyles.WS_VISIBLE, WindowStyles.WS_OVERLAPPED);
                    //    retVal = User32.DefWindowProc(hwnd, (uint)msg, wParam, lParam);
                    //    if (changed) { User32Ex.ModifyStyle(hwnd, WindowStyles.WS_OVERLAPPED, WindowStyles.WS_VISIBLE); }
                    //    handled = true;
                    //    break;
                    case WindowMessage.WM_NCUAHDRAWCAPTION:
                    case WindowMessage.WM_NCUAHDRAWFRAME:
                        // undocumented stuff for non-dwm themes that will sometimes draw old control buttons
                        handled = true;
                        break;
                    case WindowMessage.WM_NCCALCSIZE:
                        //remove non-client borders completely
                        HandleNcCalcSize(hwnd, wParam, lParam);
                        handled = true;
                        break;
                    case WindowMessage.WM_NCPAINT:
                        // prevent non-dwm flicker
                        handled = !Dwmapi.IsCompositionEnabled;
                        break;
                    case WindowMessage.WM_NCACTIVATE:
                        // handled to prevent default non-client border from showing in classic mode
                        // wParam False means draw inactive title bar (which we do nothing).

                        retVal = HandleNcActivate(hwnd, msg, wParam, retVal);
                        handled = true;
                        break;
                    case WindowMessage.WM_NCHITTEST:
                        retVal = new IntPtr((int)HandleNcHitTest(lParam.ToPoint()));
                        handled = true;
                        break;
                    case WindowMessage.WM_NCRBUTTONDOWN:
                        switch ((NcHitTest)wParam.ToInt32())
                        {
                            case NcHitTest.HTCAPTION:
                            case NcHitTest.HTSYSMENU:
                                // display sys menu
                                User32.PostMessage(hwnd, (uint)WindowMessage.WM_POPUPSYSTEMMENU, IntPtr.Zero, lParam);
                                handled = true;
                                break;
                        }
                        break;
                    case WindowMessage.WM_WINDOWPOSCHANGED:
                        HandleWindowPosChanged(hwnd, lParam);
                        break;
                    case WindowMessage.WM_DWMCOMPOSITIONCHANGED:
                        SetRegion(hwnd, 0, 0, true);
                        break;
                    case WindowMessage.WM_ERASEBKGND:
                        // prevent more flickers?
                        handled = true;
                        break;
                }
            }
            return retVal;
        }
开发者ID:soukoku,项目名称:ModernWPF,代码行数:97,代码来源:LegacyBorderManager.cs


注:本文中的System.IntPtr.ToPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。