日期:2014-05-17 浏览次数:21018 次
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern bool RedrawWindow(IntPtr hwnd, COMRECT rcUpdate, IntPtr hrgnUpdate, int flags);
[DllImport("User32.dll")]
public extern static IntPtr GetDC(System.IntPtr hWnd);
[DllImport("user32.dll")]
private static extern int GetWindowRect(IntPtr hWnd,out Rect lpRect);
//获取窗口边框矩形尺寸
public struct Rect
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
//获取指定句柄窗口矩形位置大小
Rect rect = new Rect();
GetWindowRect(winHandle, out rect);
//画矩形边框
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);
[DllImport("gdi32.dll")]
private static extern bool BitBlt(
IntPtr hdcDest, //目标设备的句柄
int nXDest, // 目标对象的左上角的X坐标
int nYDest, // 目标对象的左上角的X坐标
int nWidth, // 目标对象的矩形的宽度
int nHeight, // 目标对象的矩形的长度
IntPtr hdcSrc, // 源设备的句柄
int nXSrc, // 源对象的左上角的X坐标&nbs