我遇到了与全局Deactivate FocusVisualStyle相同的问题.
但没有一个答案可以奏效.
所以,我只是想在我的应用程序中设置所有控件FocusVisualStyle="{x:Null}",任何有效的方法来实现这一目标?
我不想单独设置每个控件.
第一次在这里提出问题时,由于某种原因,我在此处找到的解决方案似乎不起作用。当窗口变为活动状态时,我的应用程序需要设置鼠标位置。我已经设置了功能,但无法使光标属性起作用。由于某种原因,我不能真正使用Cursor.Position或任何东西。我原本希望访问聊天室以找到解决方案,但是显然我只有在20岁以后才能讲话。
所以我在这里问如何用类似的方法更改光标位置
this.Cursor.SetPosition(x,y);
谢谢您的帮助。
编辑:已经从这里尝试过作为测试:
private void MoveCursor()
{
// Set the Current cursor, move the cursor's Position,
// and set its clipping rectangle to the form.
this.Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);
Cursor.Clip = new Rectangle(this.Location, this.Size);
}
Run Code Online (Sandbox Code Playgroud)
但是编译器抱怨当前,位置,剪辑,位置,大小
最终解决方案:
using System.Runtime.InteropServices;
...
[DllImport("User32.dll")]
private static extern bool SetCursorPos(int X, int Y);
...
Point relativePoint = MouseCaptureButton.TransformToAncestor(this)
.Transform(new Point(0, 0));
Point pt = new Point(relativePoint.X + MouseCaptureButton.ActualWidth / 2,
relativePoint.Y …Run Code Online (Sandbox Code Playgroud)