C#工具提示在3D派对窗口上报告鼠标坐标 [英] C# tooltip reporting mouse coordinates on 3d party window
问题描述
这个问题是关于一个工具提示的,您可以按顺序很容易地实现
通过其坐标跟踪鼠标位置
对我而言,唯一的问题是增加了在特定位置上跟踪坐标的功能
将其设置为前台后的窗口...这不是表单,而是第三方
应用.
this question is about a tooltip that you can implement very easy in order
to track mouse location via it's coordinates
the only problem for me is to add the ability to track the coordinates on a specific
window after setting it to foreground ... and it's not a form , but a 3rd party
application .
在Visual Studio Windows窗体上对我有用的代码是
the code which works for me on the visual studio windows form is
ToolTip trackTip;
private void TrackCoordinates()
{
trackTip = new ToolTip();
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
}
void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
String tipText = String.Format("({0}, {1})", e.X, e.Y);
trackTip.Show(tipText, this, e.Location);
}
//多数民众赞成在我在网上某处看到的代码,然后在再次谷歌搜索之后又看到了 在网址中找到了msdn源:
//thats a code i have seen somewhere on the web and then again after some more googling found the msdn source at the url :
所以问题仍然存在,如果您愿意回答: 如何获取第三方的工具提示坐标(相对于Winform窗口除外)
so the question remains if you'll be kind to answer : how do i get tool tip coordinates of a 3rd party (other than Vs winform window)
推荐答案
You need to use one of the following (as it is explained in this question):
1.使用Windows窗体.添加对System.Windows.Forms的引用
1.Using Windows Forms. Add a reference to System.Windows.Forms
public static Point GetMousePositionWindowsForms()
{
System.Drawing.Point point = Control.MousePosition;
return new Point(point.X, point.Y);
}
2.使用Win32
2.Using Win32
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool GetCursorPos(ref Win32Point pt);
[StructLayout(LayoutKind.Sequential)]
internal struct Win32Point
{
public Int32 X;
public Int32 Y;
};
public static Point GetMousePosition()
{
Win32Point w32Mouse = new Win32Point();
GetCursorPos(ref w32Mouse);
return new Point(w32Mouse.X, w32Mouse.Y);
}
这篇关于C#工具提示在3D派对窗口上报告鼠标坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!