c# 鼠标获取坐标。怎么在鼠标 箭头上出现坐标。比如箭头上显示(X,Y)。

 我来答
173199732
2011-09-28 · TA获得超过268个赞
知道答主
回答量:277
采纳率:0%
帮助的人:237万
展开全部
我这是Winform版本的,就是在Form窗体中加:ToolTip控件, 然后在Form中的MouseMove事件中加:
toolTip1.Show("" + e.X + ";" + e.Y, this, new Point(e.X, e.Y));
就完了。。。

页面代码:
namespace WindowsFormsApplication1
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.label1 = new System.Windows.Forms.Label();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(227, 106);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(641, 382);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolTip toolTip1;
}
}

主要代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_MouseMove(object sender, MouseEventArgs e)
{
toolTip1.Show("" + e.X + ";" + e.Y, this, new Point(e.X, e.Y));
}
}
}
百度网友6fdd73f74
2011-09-28
知道答主
回答量:18
采纳率:0%
帮助的人:12.9万
展开全部
int x = Control.MousePosition.X;
int y = Control.MousePosition.Y;
Point p = new Point(x,y);
.net封装好的类
更多追问追答
追问
如何实现在鼠标 箭头上面显示。比如鼠标放在某个坐标上 一定时间无动作后,在箭头上显示(x,y)
追答
是做BS还是做CS 如果是BS的话 那就弹出一个层 层的location位置的P
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式