110,561
社区成员
发帖
与我相关
我的任务
分享
IntPtr DesktopHandle = GetDC(IntPtr.Zero); Graphics g = System.Drawing.Graphics.FromHdc(DesktopHandle); Pen pen = new Pen(Color.Black, 2); g.DrawRectangle(pen, rect.Left, rect.Top, winWidth, winHeight);
public class COMRECT
{
public int left;
public int top;
public int right;
public int bottom;
public COMRECT()
{
}
public COMRECT(int left, int top, int right, int bottom)
{
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}
}
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern bool RedrawWindow(IntPtr hwnd, COMRECT rcUpdate, IntPtr hrgnUpdate, int flags);
//调用后直接刷新了整个桌面屏幕,和F5效果一样,
RedrawWindow(IntPtr.Zero, null, IntPtr.Zero, 0x85);
//调用这个没有效果,想要达到刷新屏幕上坐标左100,上100,右1000,下700的矩形,使这个范围内画在屏幕上的矩形消除掉,如果该区域内有窗口,矩形会有部分是在窗口上绘制的
COMRECT re = new COMRECT(100, 100,1000,700);
RedrawWindow(IntPtr.Zero, re,IntPtr.Zero, 0x85);
//RedrawWindow函数的第4个参数查了很多资料没有找到对应的值,不知道应该使用哪个参数及对应0X的值