• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Win32Point类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetPosition

 public static Point GetPosition()
 {
     var w32Mouse = new Win32Point();
     GetCursorPos(ref w32Mouse);
     return new Point(w32Mouse.X, w32Mouse.Y);
 }
开发者ID:NGenesis,项目名称:VrPlayer.Trackers.OSVRTracker,代码行数:6,代码来源:MouseUtilities.cs


示例2: GetCursorPos

        public static IntPoint GetCursorPos()
        {
            Win32Point position = new Win32Point(0, 0);
            NativeMethods.GetCursorPos(ref position);

            return new IntPoint(position.x, position.y);
        }
开发者ID:RSchwoerer,项目名称:rooler,代码行数:7,代码来源:NativeMethods.cs


示例3: GetMousePosition

 public static int[] GetMousePosition()
 {
     Win32Point w32Mouse = new Win32Point();
     GetCursorPos(ref w32Mouse);
     int[] pos = new int[2];
     pos[0] = w32Mouse.X;
     pos[1] = w32Mouse.Y;
     return pos;
 }
开发者ID:jamest222,项目名称:MouseControl,代码行数:9,代码来源:MouseController.cs


示例4: GetMousePosition

        /// <summary>
        /// Returns the mouse cursor location.  This method is necessary during 
        /// a drag-drop operation because the WPF mechanisms for retrieving the
        /// cursor coordinates are unreliable.
        /// </summary>
        /// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
        public static Point GetMousePosition(Visual relativeTo)
        {
            Win32Point mouse = new Win32Point();
            GetCursorPos(ref mouse);

            // Using PointFromScreen instead of Dan Crevier's code (commented out below)
            // is a bug fix created by William J. Roberts.  Read his comments about the fix
            // here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
            return relativeTo.PointFromScreen(new Point((double)mouse.X, (double)mouse.Y));
        }
开发者ID:nydehi,项目名称:onesync,代码行数:16,代码来源:MouseUtilities.cs


示例5: ScreenToClient

        public static Point ScreenToClient(FrameworkElement element, IntPoint point)
        {
            PresentationSource source = PresentationSource.FromVisual(element);

            Win32Point winPt = new Win32Point(point.X, point.Y);
            NativeMethods.ScreenToClient(((HwndSource)source).Handle, ref winPt);

            Point offset = source.CompositionTarget.TransformFromDevice.Transform(new Point(winPt.x, winPt.y));

            return source.RootVisual.TransformToDescendant(element).Transform(offset);
        }
开发者ID:RSchwoerer,项目名称:rooler,代码行数:11,代码来源:NativeMethods.cs


示例6: ClientToScreen

        public static IntPoint ClientToScreen(FrameworkElement element, Point point)
        {
            PresentationSource source = PresentationSource.FromVisual(element);
            point = element.TransformToAncestor(source.RootVisual).Transform(point);

            Point offset = source.CompositionTarget.TransformToDevice.Transform(new Point(point.X, point.Y));

            Win32Point winPt = new Win32Point((int)offset.X, (int)offset.Y);
            NativeMethods.ClientToScreen(((HwndSource)source).Handle, ref winPt);

            return new IntPoint(winPt.x, winPt.y);
        }
开发者ID:RSchwoerer,项目名称:rooler,代码行数:12,代码来源:NativeMethods.cs


示例7: GetMousePosition

        public static Point GetMousePosition(Visual relativeTo)
        {
            Win32Point mouse = new Win32Point();
            GetCursorPos(ref mouse);

            System.Windows.Interop.HwndSource presentationSource = 
                (System.Windows.Interop.HwndSource)PresentationSource.FromVisual(relativeTo);

            ScreenToClient(presentationSource.Handle, ref mouse);

            GeneralTransform transform = relativeTo.TransformToAncestor(presentationSource.RootVisual);

            Point offset = transform.Transform(new Point(0, 0));

            return new Point(mouse.X - offset.X, mouse.Y - offset.Y);
        }
开发者ID:Saroko-dnd,项目名称:My_DZ,代码行数:16,代码来源:DragDropScrollViewer.cs


示例8: GetMousePosition

        /// <summary>
        /// Returns the mouse cursor location.  This method is necessary during 
        /// a drag-drop operation because the WPF mechanisms for retrieving the
        /// cursor coordinates are unreliable.
        /// </summary>
        /// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
        public static Point GetMousePosition( Visual relativeTo )
        {
            Win32Point mouse = new Win32Point();
            GetCursorPos( ref mouse );

            // Using PointFromScreen instead of Dan Crevier's code (commented out below)
            // is a bug fix created by William J. Roberts.  Read his comments about the fix
            // here: http://www.codeproject.com/useritems/ListViewDragDropManager.asp?msg=1911611#xx1911611xx
            return relativeTo.PointFromScreen( new Point( (double)mouse.X, (double)mouse.Y ) );

            #region Commented Out
            //System.Windows.Interop.HwndSource presentationSource =
            //    (System.Windows.Interop.HwndSource)PresentationSource.FromVisual( relativeTo );
            //ScreenToClient( presentationSource.Handle, ref mouse );
            //GeneralTransform transform = relativeTo.TransformToAncestor( presentationSource.RootVisual );
            //Point offset = transform.Transform( new Point( 0, 0 ) );
            //return new Point( mouse.X - offset.X, mouse.Y - offset.Y );
            #endregion // Commented Out
        }
开发者ID:iarray,项目名称:LoveMusic,代码行数:25,代码来源:MouseUtilities.cs


示例9: GetMousePosition

        public static Point GetMousePosition(Visual relativeTo)
        {
            Win32Point mouse = new Win32Point();
            GetCursorPos(ref mouse);

            System.Windows.Interop.HwndSource presentationSource =
                (System.Windows.Interop.HwndSource)PresentationSource.FromVisual(relativeTo);

            ScreenToClient(presentationSource.Handle, ref mouse);

            GeneralTransform transform = relativeTo.TransformToAncestor(presentationSource.RootVisual);

            Point offset = transform.Transform(new Point(0, 0));
            //
            //             Point p = new Point(mouse.X - offset.X, mouse.Y - offset.Y);
            //             System.Diagnostics.Debug.WriteLine(string.Format("mouse {0:0.0}|{1:0.0} offset {2:0.0}|{3:0.0} res {4:0.0}|{5:0.0}",
            //                 mouse.X, mouse.Y, offset.X, offset.Y, p.X, p.Y));

            return new Point(mouse.X - offset.X, mouse.Y - offset.Y);
        }
开发者ID:xcasadio,项目名称:FlowGraph,代码行数:20,代码来源:MouseUtilities.cs


示例10: GetMousePosition

 public static Win32Point GetMousePosition()
 {
     Win32Point w32Mouse = new Win32Point();
     GetCursorPos(ref w32Mouse);
     return w32Mouse;
 }
开发者ID:ShallDen,项目名称:EnglishHelper,代码行数:6,代码来源:MouseHelper.cs


示例11: ClientToScreen

		private static extern bool ClientToScreen (IntPtr hWnd, ref Win32Point point);
开发者ID:vnan122,项目名称:mono,代码行数:1,代码来源:DataGridViewTest.cs


示例12: OneClickComboBoxCell

		public void OneClickComboBoxCell ()
		{
			Form form = null;

			try
			{
				// Create a form, a text label, and a data-grid-view.
				form = new Form ();
				Label label = new Label ();
				label.Text = "Label";
				label.Parent = form;
				ClickableDataGridView dgv = new ClickableDataGridView ();
				dgv.Parent = form;

				// Create a combo-box column.
				DataGridViewComboBoxColumn cbCol = new DataGridViewComboBoxColumn ();
				cbCol.HeaderText = "Name";
				dgv.Columns.Add (cbCol);

				// .NET requires that all possible values for combo-boxes
				// in a column are added to the column.
				cbCol.Items.Add ("Item1");
				cbCol.Items.Add ("Item2");
				cbCol.Items.Add ("Item3");
				cbCol.Items.Add ("Item4");

				// Set up the contents of the data-grid.
				dgv.Rows.Add ("Item1");
				dgv.Rows.Add ("Item2");

				// Select the cell.
				dgv.CurrentCell = dgv.Rows[0].Cells[0];

				// Focus the data-grid-view.  (Without this, its Leave
				// event won't get called when something outside of the
				// data-grid-view gets focused.)
				dgv.Focus ();

				// Show the form, let it draw.
				form.Show ();
				Application.DoEvents ();

				// Locate the drop-down button.  (This code is taken from mono-winforms,
				// from the private method DataGridViewComboBoxCell.CalculateButtonArea(),
				// and was then hacked mercilessly.)
				Rectangle button_area = Rectangle.Empty;
				{
					int border = 3 /* ThemeEngine.Current.Border3DSize.Width */;
					const int button_width = 16;
					Rectangle text_area = dgv.GetCellDisplayRectangle (0, 0, false);
					button_area.X = text_area.Right - button_width - border;
					button_area.Y = text_area.Y + border;
					button_area.Width = button_width;
					button_area.Height = text_area.Height - 2 * border;
				}

				// Click on the drop-down button.
				int x = button_area.X + (button_area.Width / 2);
				int y = button_area.Y + (button_area.Height / 2);
				if (Environment.OSVersion.Platform == PlatformID.Win32NT
				&& Type.GetType ("Mono.Runtime") == null)
				{
					// Calling OnMouseDownInternal () in Win32 doesn't work.
					// My best guess as to why is that the WinForms ComboBox
					// is a wrapper around the ComCtl control, e.g. similar
					// to the reason that Paint event-handlers don't work on
					// TreeView.  So we go through all this rigamarole to
					// simulate a mouse click.

					// First, get the location of the desired mouse-click, in
					// data-grid-view coordinates.
					Win32Point ptGlobal = new Win32Point ();
					ptGlobal.x = x + dgv.Location.X;
					ptGlobal.y = y + dgv.Location.Y;

					// Convert that to screen coordinates.
					ClientToScreen (form.Handle, ref ptGlobal);

					// Move the mouse-pointer there.  (Yes, this really appears
					// to be necessary.)
					SetCursorPos (ptGlobal.x, ptGlobal.y);

					// Convert screen coordinates to mouse coordinates.
					ptGlobal.x *= (65535 / SystemInformation.VirtualScreen.Width);
					ptGlobal.y *= (65535 / SystemInformation.VirtualScreen.Height);

					// Finally, fire a mouse-down and mouse-up event.
					mouse_event (MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_ABSOLUTE,
						ptGlobal.x, ptGlobal.y, 0, 0);
					mouse_event (MOUSEEVENTF_LEFTUP|MOUSEEVENTF_ABSOLUTE,
						ptGlobal.x, ptGlobal.y, 0, 0);

					// Let the system process these events.
					Application.DoEvents ();
				}
				else
				{
					// And this is how the same code is done under Linux.
					// (No one should wonder why I prefer Mono to MS Windows .NET ;-)
					MouseEventArgs me = new MouseEventArgs (MouseButtons.Left, 1, x, y, 0);
//.........这里部分代码省略.........
开发者ID:vnan122,项目名称:mono,代码行数:101,代码来源:DataGridViewTest.cs


示例13: GetMousePosition

 public static Vector2 GetMousePosition()
 {
     Win32Point w32Mouse = new Win32Point();
     GetCursorPos(ref w32Mouse);
     return new Vector2(w32Mouse.X, w32Mouse.Y);
 }
开发者ID:smad2005,项目名称:PathOfExileStashSorter,代码行数:6,代码来源:MouseTools.cs


示例14: GetCursorPos

 private static extern bool GetCursorPos( ref Win32Point pt );
开发者ID:iarray,项目名称:LoveMusic,代码行数:1,代码来源:MouseUtilities.cs


示例15: OnMouseMove

 protected override void OnMouseMove(MouseEventArgs e)
 {
     base.OnMouseMove(e);
     if (SettingMode)
     {
         Win32Point point = new Win32Point();
         GetCursorPos(ref point);
         this.txtPosX.Text = point.X.ToString();
         this.txtPosY.Text = point.Y.ToString();
     }
 }
开发者ID:taka9,项目名称:MoveMousePosition,代码行数:11,代码来源:MainWindow.xaml.cs


示例16: GetMousePosition

 public static PointF GetMousePosition()
 {
     Win32Point w32Mouse = new Win32Point();
     GetCursorPos(ref w32Mouse);
     return new PointF(w32Mouse.X, w32Mouse.Y);
 }
开发者ID:madeso,项目名称:neko,代码行数:6,代码来源:MainWindow.xaml.cs


示例17: GetMousePosition

 /// <summary>
 /// Returns the mouse cursor location.  This method is necessary during
 /// a drag-drop operation because the WPF mechanisms for retrieving the
 /// cursor coordinates are unreliable.
 /// </summary>
 /// <param name="relativeTo">The Visual to which the mouse coordinates will be relative.</param>
 public static Point GetMousePosition(Visual relativeTo)
 {
     Win32Point mouse = new Win32Point();
     GetCursorPos(ref mouse);
     return relativeTo.PointFromScreen(new Point((double)mouse.X, (double)mouse.Y));
 }
开发者ID:networkelements,项目名称:Outopos,代码行数:12,代码来源:Extensions.cs


示例18: GetMousePosition

 static System.Drawing.Point GetMousePosition()
 {
     Win32Point w32Mouse = new Win32Point();
     GetCursorPos(ref w32Mouse);
     return new System.Drawing.Point(w32Mouse.X, w32Mouse.Y);
 }
开发者ID:Effix,项目名称:LedBadge,代码行数:6,代码来源:ScreenCapture.cs


示例19: GetMousePosition

 public static Point GetMousePosition()
 {
     Win32Point point = new Win32Point();
     GetCursorPos(ref point);
     return new Point(point.x, point.y);
 }
开发者ID:garafu,项目名称:Twining,代码行数:6,代码来源:User32.cs


示例20: getCursorPos

 /// <summary>
 /// Returns the current mouse pointer position
 /// </summary>
 /// <returns>x,y location of mouse pointer</returns>
 private Point getCursorPos()
 {
     Win32Point w32Mouse = new Win32Point();
     GetCursorPos(ref w32Mouse);
     return new Point(w32Mouse.X, w32Mouse.Y);
 }
开发者ID:glwu,项目名称:acat,代码行数:10,代码来源:MouseGridScanWindow.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WinWindow类代码示例发布时间:2022-05-24
下一篇:
C# Win32类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap