C#桌面图形
我想用红点突出显示鼠标光标,但程序只在屏幕的3/4处绘制。如果我将光标移到屏幕右侧,红色圆点将消失。谁能帮助我,如何“使用”整个屏幕C#桌面图形,c#,graphics,user32,intptr,C#,Graphics,User32,Intptr,我想用红点突出显示鼠标光标,但程序只在屏幕的3/4处绘制。如果我将光标移到屏幕右侧,红色圆点将消失。谁能帮助我,如何“使用”整个屏幕 [DllImport("User32.dll")] public static extern IntPtr GetDC(IntPtr hwnd); public void moveCursor() { while (true) { System.Windows.Point pMouse = Mou
[DllImport("User32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
public void moveCursor()
{
while (true)
{
System.Windows.Point pMouse = MouseControl.GetCursorPosition();
if (pMouse != null)
{
IntPtr desktopPtr = GetDC(IntPtr.Zero);
this.x = (int)pMouse.X;
this.y = (int)pMouse.Y;
using (Graphics g = Graphics.FromHdcInternal(desktopPtr))
{
g.FillEllipse(action ? Brushes.Blue : Brushes.Red, (int)(x * 1.25 - 27 / 2), (int)(y * 1.25 - 27 / 2), (int)(27 * screen), (int)(27 * screen));
}
ReleaseDC(IntPtr.Zero, desktopPtr);
}
Thread.Sleep(5);
ToggleDesktopIcons();
}
}
为什么
*1.25
。意思它将在屏幕外绘制。什么是屏幕
?屏幕的值为1。当我得到鼠标的xy坐标时,它不是像素,所以我必须转换它。我发现了一个链接,它解释了为什么1.25看起来像是Windows10的比例因子。您的解决方案可能无法在其他设备上运行。