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


C# POINT类代码示例

本文整理汇总了C#中POINT的典型用法代码示例。如果您正苦于以下问题:C# POINT类的具体用法?C# POINT怎么用?C# POINT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetWindowSize

		private Dictionary<string, int> GetWindowSize(string processName)
		{
			IntPtr handle = IntPtr.Zero;
			foreach (Process process in Process.GetProcesses())
			{


				if (process.MainWindowTitle.IndexOf(processName) >= 0)
				{
					handle = process.MainWindowHandle;
				}
			}
			if (handle == IntPtr.Zero)
				throw new WindowNotFoundException();

			RECT rect = new RECT(); POINT point = new POINT();
			GetClientRect(handle, out rect);
			ClientToScreen(handle, out point);
			var result = new Dictionary<string, int>();
			result.Add("width", (int)(rect.right - rect.left));
			result.Add("height", (int)(rect.bottom - rect.top));
			result.Add("x", (int)point.x);
			result.Add("y", (int)point.y);
			return result;
		}
开发者ID:mok-aster,项目名称:NasneCapture,代码行数:25,代码来源:WIndowCapture.cs

示例2: MainAppContext

        public MainAppContext()
        {
            NotifyIcon trayIcon = new NotifyIcon() { Icon = Properties.Resources.TopMost, Text = "MakeTopMost", Visible = true };
            trayIcon.Click += (s, e) =>
                {
                    if (this.lastMenu != null)
                    {
                        this.lastMenu.Dispose();
                    }

                    this.lastMenu = this.CreateMenu();

                    NativeWindow trayIconWindow = (NativeWindow)typeof(NotifyIcon).GetField("window", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(trayIcon);
                    POINT cursorLocation = new POINT(); NativeMethods.GetCursorPos(out cursorLocation);
                    SystemWindow.ForegroundWindow = new SystemWindow(trayIconWindow.Handle);
                    NativeMethods.TrackPopupMenuEx(new HandleRef(this.lastMenu, this.lastMenu.Handle), 72, cursorLocation.X, cursorLocation.Y, new HandleRef(trayIconWindow, trayIconWindow.Handle), IntPtr.Zero);
                    NativeMethods.PostMessage(new HandleRef(trayIconWindow, trayIconWindow.Handle), 0, IntPtr.Zero, IntPtr.Zero);
                };

            this.ThreadExit += (s, e) =>
                {
                    trayIcon.Dispose();
                    if (this.lastMenu != null)
                    {
                        this.lastMenu.Dispose();
                    }
                };
        }
开发者ID:stefan-baumann,项目名称:MakeTopMost,代码行数:28,代码来源:Program.cs

示例3: HandleMouseEvent

        private int HandleMouseEvent(int inEvtDispId, IHTMLEventObj pIEventObj)
        {
            // WinLive 160252: MSHTML throws a COMException with HRESULT 0x8000FFFF (E_UNEXPECTED) when calling
            // IHTMLPaintSite.TransformGlobalToLocal if the table has no height.
            IHTMLElement tableElement = (IHTMLElement)_table;
            if (tableElement.offsetHeight <= 0 || tableElement.offsetWidth <= 0)
            {
                return HRESULT.S_FALSE;
            }

            // compute the element local coordinates of the point
            POINT clientMouseLocation = new POINT();
            clientMouseLocation.x = pIEventObj.clientX;
            clientMouseLocation.y = pIEventObj.clientY;
            POINT localMouseLocation = new POINT();
            _paintSite.TransformGlobalToLocal(clientMouseLocation, ref localMouseLocation);

            // determine if the point is within our bounds
            int tableWidth = tableElement.offsetWidth + 4; // extra padding for mouse handling at right edge
            Rectangle elementBounds = new Rectangle(-1, -1, tableWidth, tableElement.offsetHeight + 1);
            bool mouseInElement = elementBounds.Contains(localMouseLocation.x, localMouseLocation.y);

            if (mouseInElement || _sizingOperation.InProgress)
            {
                // create args
                TableColumnMouseEventArgs mouseEventArgs = new TableColumnMouseEventArgs(
                    new Point(clientMouseLocation.x, clientMouseLocation.y),
                    new Point(localMouseLocation.x, localMouseLocation.y));

                // fire the event
                switch (inEvtDispId)
                {
                    case DISPID_HTMLELEMENTEVENTS2.ONMOUSEMOVE:
                        OnMouseMove(mouseEventArgs);
                        break;
                    case DISPID_HTMLELEMENTEVENTS2.ONMOUSEDOWN:
                        OnMouseDown(mouseEventArgs);
                        break;
                    case DISPID_HTMLELEMENTEVENTS2.ONMOUSEUP:
                        OnMouseUp(mouseEventArgs);
                        break;
                    default:
                        Trace.Fail("unexpected event id");
                        break;
                }

                // indicate whether we should mask the event from the editor
                return mouseEventArgs.Handled ? HRESULT.S_OK : HRESULT.S_FALSE;

            }
            else
            {
                // if the mouse is not inside the element the end sizing
                _sizingOperation.EndSizing();
            }

            // event not handled
            return HRESULT.S_FALSE;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:59,代码来源:TableColumnSizeEditor.cs

示例4: UpperLeftCornerOfWindow

        public static System.Drawing.Point UpperLeftCornerOfWindow(IntPtr hWnd)
        {
            Interop.POINT p = new POINT(0, 0);
            ScreenToClient(hWnd, ref p);

            // Make these positive
            return new Point(p.X * -1, p.Y * -1);
        }
开发者ID:philc,项目名称:InstallPad,代码行数:8,代码来源:Interop.cs

示例5: WindowFormPoint

        public static IntPtr WindowFormPoint(System.Drawing.Point point)
        {
            var p = new POINT();
            p.x = point.X;
            p.y = point.Y;

            return WindowFromPoint(p);
        }
开发者ID:namoshika,项目名称:SnkLib.Win.Forms.DockingWindow,代码行数:8,代码来源:API_SendInput.cs

示例6: GetWindowTextUnderCursor

        public static string GetWindowTextUnderCursor()
        {
            POINT pointCursor = new POINT();

            if (!(GetCursorPos(out pointCursor))) return string.Empty;

            return GetWindowText(pointCursor);
        }
开发者ID:bleissem,项目名称:automate,代码行数:8,代码来源:WindowRecorder.cs

示例7: GetCurrentMonitor

 public static IntPtr GetCurrentMonitor()
 {
     POINT point = new POINT();
     if (!GetCursorPos(out point))
     {
         throw new Win32Exception(Marshal.GetLastWin32Error());
     }
     return MonitorFromPoint(point, MONITOR_DEFAULTTONEAREST);
 }
开发者ID:alexhorn,项目名称:BrightnessControl,代码行数:9,代码来源:DisplayConfiguration.cs

示例8: NativeScreenToClient

		//********************************
		//using DllImports from DLL_User32
		//********************************
		public static Point NativeScreenToClient(IntPtr window, Point originalPoint)
		{
			POINT pOINT = new POINT(originalPoint.X, originalPoint.Y);
			if (ScreenToClient(window, ref pOINT))
			{
				return new Point(pOINT.x, pOINT.y);
			}
			return Point.Empty;
		}	
开发者ID:paul-green,项目名称:O2.Platform.Scripts,代码行数:12,代码来源:Win32_Helper_Methods.cs

示例9: UpdateLayeredWindow

 public static extern int UpdateLayeredWindow(IntPtr hWnd, 
     IntPtr hdcDst,
     ref POINT pptDst, 
     ref SIZE psize,
     IntPtr hdcSrc, 
     ref POINT pptSrc, 
     uint crKey, 
     ref BLENDFUNCTION pblend, 
     uint dwFlags);
开发者ID:Wiladams,项目名称:NewTOAPIA,代码行数:9,代码来源:User32_Window.cs

示例10: TransformGlobalToLocal

 public Point TransformGlobalToLocal(Point ptGlobal)
 {
     POINT pointLocal = new POINT();
     POINT pointGlobal = new POINT();
     pointGlobal.x = ptGlobal.X;
     pointGlobal.y = ptGlobal.Y;
     HTMLPaintSite.TransformGlobalToLocal(pointGlobal, ref pointLocal);
     return new Point(pointLocal.x, pointLocal.y);
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:9,代码来源:TableCellEditingElementBehavior.cs

示例11: ClientToScreen

 /// <summary>
 /// Clients to screen.
 /// </summary>
 /// <param name="handle">A handle.</param>
 /// <param name="point">A point.</param>
 /// <returns></returns>
 public static POINT ClientToScreen(WindowHandle handle, POINT point)
 {
     POINT point1 = point;
     if (!ClientToScreen(handle, ref point1))
     {
         throw new Win32Exception();
     }
     return point1;
 }
开发者ID:XtremeKevinChow,项目名称:smartwin32api,代码行数:15,代码来源:UnsafeNativeMethods.cs

示例12: FindWindowAtPos

 /// <summary>
 /// Функция находит дочернее окно в данной точке.
 /// </summary>
 /// <param name="pt">Точка в абсолютных координатах</param>
 /// <returns>Возвращает дескриптор окна</returns>
 public IntPtr FindWindowAtPos(System.Drawing.Point pt)
 {
     FindedHandle = IntPtr.Zero;
       POINT APIpt = new POINT();
       APIpt.X = pt.X;
       APIpt.Y = pt.Y;
       GCHandle GCPoint = GCHandle.Alloc(APIpt);
       EnumWindowsProc cbFinder = new EnumWindowsProc(FindNextLevelWindowAtPos);
       EnumChildWindows(ParentHandle,FindNextLevelWindowAtPos, GCHandle.ToIntPtr(GCPoint));
       return FindedHandle;
 }
开发者ID:alexryassky,项目名称:actionlogger,代码行数:16,代码来源:cEnumerator.cs

示例13: TransformScreenToClient

        /// <summary>
        ///     Transform a point from "screen" coordinate space into the
        ///     "client" coordinate space of the window.
        /// </summary>
        public static Point TransformScreenToClient(this HwndSource hwndSource, Point point)
        {
            HWND hwnd = new HWND(hwndSource.Handle);

            POINT pt = new POINT();
            pt.x = (int)point.X;
            pt.y = (int)point.Y;

            NativeMethods.ScreenToClient(hwnd, ref pt);

            return new Point(pt.x, pt.y);
        }
开发者ID:GoldRenard,项目名称:DMOAdvancedLauncher,代码行数:16,代码来源:HwndSourceExtensions.cs

示例14: MouseUpEventArgs

        public MouseUpEventArgs(MouseButtons button, POINT pt, IntPtr hWnd)
        {
            Button = button;
            ScreenPoint = new Point(pt.x, pt.y);

            if (hWnd == IntPtr.Zero)
                return;

            WindowHandle = hWnd;
            PInvoke.ScreenToClient(hWnd, ref pt);
            WindowPoint = new Point(pt.x, pt.y);
        }
开发者ID:Ragnarock70,项目名称:Helper,代码行数:12,代码来源:Handler.cs

示例15: SetPosition

        public static void SetPosition(int x, int y)
        {
            POINT pt = new POINT(x, y);

            if (m_windowHandle != IntPtr.Zero)
            {
                unsafe
                {
                    ClientToScreen(m_windowHandle.ToPointer(), &pt);
                }
            }
            SetCursorPos(pt.X, pt.Y);
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:13,代码来源:MyWindowsMouse.cs


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